Expo dev build for Android internal distribution crashes in emulator

Hi! I’m using SDK 46 and an expo-dev-build, I have built an Android internal distribution build and installed the app in my Android Emulator (Nexus 6P API 31, Android 12 x86_64).

After tap in the app icon, the app immediately crashes, this is the log excerpt I found with adb logcat, it seems that the issue is with some UTF8 characters…¿¿??

09-06 19:27:17.476 14940 14988 F r_de_tecnologi: java_vm_ext.cc:579] JNI DETECTED ERROR IN APPLICATION: input is not valid Modified UTF-8: illegal continuation byte 0x25

09-06 19:27:17.057 14940 14940 I r_de_tecnologi: Late-enabling -Xcheck:jni
09-06 19:27:17.092 14940 14940 W r_de_tecnologi: Unexpected CPU variant for X86 using defaults: x86_64
09-06 19:27:17.153 14940 14940 V GraphicsEnvironment: ANGLE Developer option for ‘com.mgscreativa.demostrador_de_tecnologia’ set to: ‘default’
09-06 19:27:17.323 14940 14940 V fb-UnpackingSoSource: locked dso store /mnt/expand/37952af6-2ccc-4bd6-91f6-fe38ab96fb79/user/0/com.mgscreativa.demostrador_de_tecnologia/lib-main
09-06 19:27:17.325 14940 14940 I fb-UnpackingSoSource: dso store is up-to-date: /mnt/expand/37952af6-2ccc-4bd6-91f6-fe38ab96fb79/user/0/com.mgscreativa.demostrador_de_tecnologia/lib-main
09-06 19:27:17.325 14940 14940 V fb-UnpackingSoSource: releasing dso store lock for /mnt/expand/37952af6-2ccc-4bd6-91f6-fe38ab96fb79/user/0/com.mgscreativa.demostrador_de_tecnologia/lib-main
09-06 19:27:17.417 14940 14988 D SoLoader: libfbjni.so not found on /mnt/expand/37952af6-2ccc-4bd6-91f6-fe38ab96fb79/user/0/com.mgscreativa.demostrador_de_tecnologia/lib-main
09-06 19:27:17.417 14940 14988 D SoLoader: libfbjni.so found on /mnt/expand/37952af6-2ccc-4bd6-91f6-fe38ab96fb79/app/~~e6VBcfu_Pl1R0BSl0T6_Lw==/com.mgscreativa.demostrador_de_tecnologia-lvur7wrFE_dWjTIJpT6ETw==/lib/x86_64
09-06 19:27:17.422 14940 14988 D SoLoader: libflipper.so not found on /mnt/expand/37952af6-2ccc-4bd6-91f6-fe38ab96fb79/user/0/com.mgscreativa.demostrador_de_tecnologia/lib-main
09-06 19:27:17.422 14940 14988 D SoLoader: libflipper.so found on /mnt/expand/37952af6-2ccc-4bd6-91f6-fe38ab96fb79/app/~~e6VBcfu_Pl1R0BSl0T6_Lw==/com.mgscreativa.demostrador_de_tecnologia-lvur7wrFE_dWjTIJpT6ETw==/lib/x86_64
09-06 19:27:17.456 14940 14990 W unknown:ReconnectingWebSocket: Couldn’t connect to “ws://localhost:8081/message?device=sdk_gphone64_x86_64%20-%2012%20-%20API%2031&app=com.mgscreativa.demostrador_de_tecnologia&clientid=DevLauncherDevSupportManager”, will silently retry
09-06 19:27:17.461 14940 14940 W r_de_tecnologi: Accessing hidden field Landroid/view/View;->mKeyedTags:Landroid/util/SparseArray; (unsupported, reflection, allowed)
09-06 19:27:17.461 14940 14940 W r_de_tecnologi: Accessing hidden field Landroid/view/View;->mListenerInfo:Landroid/view/View$ListenerInfo; (unsupported, reflection, allowed)
09-06 19:27:17.461 14940 14940 W r_de_tecnologi: Accessing hidden field Landroid/view/View$ListenerInfo;->mOnClickListener:Landroid/view/View$OnClickListener; (unsupported, reflection, allowed)
09-06 19:27:17.464 14940 14940 I flipper : flipper: FlipperClient::addPlugin Inspector
09-06 19:27:17.464 14940 14940 I flipper : flipper: FlipperClient::addPlugin React
09-06 19:27:17.465 14940 14940 I flipper : flipper: FlipperClient::addPlugin Databases
09-06 19:27:17.467 14940 14940 I flipper : flipper: FlipperClient::addPlugin Preferences
09-06 19:27:17.467 14940 14940 I flipper : flipper: FlipperClient::addPlugin CrashReporter
09-06 19:27:17.469 14940 14940 I flipper : flipper: FlipperClient::addPlugin Network
09-06 19:27:17.471 362 410 W RanchuHwc: validateDisplay: layer 156 CompositionType 1, fallback
09-06 19:27:17.473 362 410 W RanchuHwc: presentDisplay display has no layers to compose, flushing client target buffer.
09-06 19:27:17.476 14940 14988 F r_de_tecnologi: java_vm_ext.cc:579] JNI DETECTED ERROR IN APPLICATION: input is not valid Modified UTF-8: illegal continuation byte 0x25
09-06 19:27:17.476 14940 14988 F r_de_tecnologi: java_vm_ext.cc:579] string: ‘ws://localhost:9089?medium=1&sdk_version=4&app=Demostrador%20De%20Tecnolog�%ADa&device_id=unknown&device=sdk_gphone64_x86_64%20-%2012%20-%20API%2031&os=Android’

Hey @mgscreativa,

Are you using the Flipper package in your project as a dependency?

Hi! I don’t think so.

“dependencies”: {
@expo/vector-icons”: “^13.0.0”,
@react-native-async-storage/async-storage”: “~1.17.8”,
@react-native-community/netinfo”: “9.3.0”,
@react-navigation/bottom-tabs”: “^6.3.2”,
@react-navigation/native”: “^6.0.11”,
@react-navigation/native-stack”: “^6.2.2”,
“expo”: “^46.0.0”,
“expo-asset”: “~8.6.1”,
“expo-constants”: “~13.2.4”,
“expo-dev-client”: “~1.2.1”,
“expo-device”: “~4.3.0”,
“expo-font”: “~10.2.0”,
“expo-linking”: “~3.2.2”,
“expo-notifications”: “~0.16.1”,
“expo-splash-screen”: “~0.16.2”,
“expo-status-bar”: “~1.4.0”,
“expo-system-ui”: “~1.3.0”,
“expo-task-manager”: “~10.3.0”,
“expo-updates”: “~0.14.5”,
“lodash”: “^4.17.21”,
“react”: “18.0.0”,
“react-dom”: “18.0.0”,
“react-native”: “0.69.5”,
“react-native-safe-area-context”: “4.3.1”,
“react-native-screens”: “~3.15.0”,
“react-native-url-polyfill”: “^1.3.0”,
“react-native-web”: “~0.18.7”,
“react-native-webview”: “11.23.0”,
“zustand”: “^4.0.0”
},
“devDependencies”: {
@babel/core”: “^7.18.6”,
@types/lodash”: “^4.14.182”,
@types/react”: “~18.0.0”,
@types/react-native”: “~0.69.1”,
@typescript-eslint/eslint-plugin”: “^5.33.0”,
@typescript-eslint/parser”: “^5.33.0”,
“eslint-plugin-prettier”: “^4.2.1”,
“eslint-plugin-react”: “^7.30.1”,
“eslint-plugin-react-hooks”: “^4.6.0”,
“jest”: “^26.6.3”,
“jest-expo”: “^46.0.0”,
“prettier”: “^2.7.1”,
“react-test-renderer”: “18.0.0”,
“typescript”: “^4.6.3”
}
}

Want to add that the very same apk works just fine in my Xiaomi Mi a2

Thanks for sharing the dependencies list. This doesn’t seem like an issue with expo-dev-client. One thing I can suggest is that if you are using a custom font, try removing it and re-build the app to test it on the device that it is crashing. Maybe the Android Emulator you are using does not support a specific character.

I’m using a virtual device created with AVD Manager in Android Studio. That’s really weird.

Any suggestion to create the correct virtual device?

imagen

It is indeed quite weird. I also use the Android emulator with similar AVD settings. My suggestion here is to create another AVD and use a different device (other than nexus 6P), and then test on it.

Hi! @amanhimself tried with a brand new Pixel 4 emu and the same result…

Did you try not using the font and then run the project on Android emulator?

If you can share a minimal reproducible example, I can clone it on my end and see what’s happening.

Hi @mgscreativa

What changed between when it was working and when it was crashing? Does it work on iOS? Or other Android devices? Or other Android versions? Or did it work before upgrading to SDK 46? Or did you previously build a different way?

Also, can you create a new app and build that to test if it also crashes in the same way?

Hi @amanhimself I didn’t because after reinstalling my Linux Mint box and using latest Android studio the very same binary worked without any issues…

Thanks @wodin!
1- Didn’t change anything because the binary worked before I reinstalled my Linux mint box
2- The very same binary does work on iOS and my Android physical device (Xiaomi Mi A2), didn’t tried another android SDK, will try.
3- It worked on SDK 46 before I reinstalled my Linux Mint box, didn’t do a backup of my Android Studio emu settings…
4- Will try

OK, so “what changed” was: you reinstalled Linux mint.
I don’t know why that would have made a difference, though.

I’m a bit unsure of if you’re still having a problem now. The following seems to imply that it’s working after you reinstalled Linux Mint?

1 Like

Nope, to clarify, after reinstalling LM and AS with the mentioned emulator, the binary stopped working, but it does work on my Xiaomi phone

OK. I am not sure why that would be, but it looks like some sort of character encoding issue.

It seems like the app name is written in some character encoding other than UTF-8, but something in the emulator is trying to interpret it as a UTF-8 string:

I am guessing this part “�%AD” is supposed to be an “i”? Any idea where the weird characters are coming from?

Hi @wodin thanks for pointing that out! My app name is Demostrador de tecnología (technology demonstrator), maybe that accented í is causing the issue. But it worked before I reinstalled LM from 20.3 to LM 21.

Any hints on that accented í?

Edit1: Rebuilt the very same app, no changes, for android internal distribution and no luck, the same error in logcat

Edit2: Excerpt from app.json

{
  "expo": {
    "name": "Demostrador De Tecnología",
...
...

Edit3: Reviewing my git history on app.json and app.config.js, the accented í is there since the initial commit, done on 2022 Jul 05!

Edit 4: Found this screenshot form my backup before fresh installing LM 21, will try with API 30 to see what happens
imagen

Edit 5: Mi manigfest file is ok it seems:

{
   "name":"Demostrador De Tecnología",
...
...
   "sdkVersion":"46.0.0",
...
...
   "description":"Demostrador De Tecnología companion app",

Yes, I believe so, although I am not sure why.

If I take that string and encode it as UTF-8, then the bytes representing the accented “i” are:
0xc3, 0xad

So the “%AD” part in the error makes sense. But the “�” part is wrong and implies that something mangled that byte for some reason. And given that it works on your phone, it seems like it must be something on the emulator.

What do you get if you run the following:

grep name app.json | hexdump -C

Here you have it, I set app params in the app.config.js, even name, slug, and desc, but for this test I copy/paste name param into app.json.

grep name app.json | hexdump -C

00000000  20 20 20 20 22 6e 61 6d  65 22 3a 20 22 44 65 6d  |    "name": "Dem|
00000010  6f 73 74 72 61 64 6f 72  20 44 65 20 54 65 63 6e  |ostrador De Tecn|
00000020  6f 6c 6f 67 c3 ad 61 22  2c 0a                    |olog..a",.|
0000002a

grep name app.config.js | hexdump -C

00000000  63 6f 6e 73 74 20 6e 61  6d 65 20 3d 20 27 44 65  |const name = 'De|
00000010  6d 6f 73 74 72 61 64 6f  72 20 44 65 20 54 65 63  |mostrador De Tec|
00000020  6e 6f 6c 6f 67 c3 ad 61  27 3b 0a 20 20 20 20 6e  |nolog..a';.    n|
00000030  61 6d 65 2c 0a 20 20 20  20 64 65 73 63 72 69 70  |ame,.    descrip|
00000040  74 69 6f 6e 3a 20 60 24  7b 6e 61 6d 65 7d 20 63  |tion: `${name} c|
00000050  6f 6d 70 61 6e 69 6f 6e  20 61 70 70 60 2c 0a     |ompanion app`,.|
0000005f

Well, I think the issue it’s indeed with some flipper dependency, but I have none!

According with this RN issue and this flipper issue it seems that I need to bump the flipper version as stated in this comment :

android/gradle.properties
FLIPPER_VERSION=0.144.0

How can I do that on expo for my dev build?

Edit1: Seems to be a mention to flipper in the Run gradlew expo build step:

> Task :react-native-webview:javaPreCompileDebug
> Task :react-native-webview:compileDebugJavaWithJavac
> Task :react-native-webview:bundleLibCompileToJarDebug
[stderr] Note: Some input files use or override a deprecated API.
[stderr] Note: Recompile with -Xlint:deprecation for details.
[stderr] Note: /home/expo/workingdir/build/node_modules/react-native-webview/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java uses unchecked or unsafe operations.
[stderr] Note: Recompile with -Xlint:unchecked for details.
> Task :app:compileDebugJavaWithJavac
[stderr] Note: /home/expo/workingdir/build/android/app/src/debug/java/com/mgscreativa/demostrador_de_tecnologia/ReactNativeFlipper.java uses or overrides a deprecated API.
[stderr] Note: Recompile with -Xlint:deprecation for details.
> Task :app:compressDebugAssets
> Task :app:processDebugJavaRes NO-SOURCE
> Task :expo:processDebugJavaRes NO-SOURC

Edit2: Tested wit AVD devices with API 29, 30 and 31 and the result is the same, app crashes. I’m starting to think that maybe the issue is some change in Expo SDK 46 that triggers some Flipper usage in development builds, maybe the flipper version bump workaround should help, but I don’t know how to tell expo to do that.

Hi! @amanhimself I think I gathered enough data to test by the expo team