Google Play builds of Android crashing on start with error FATAL EXCEPTION: create_react_context
See original GitHub issueDescription
After uploading an aab to Google Play, then downloading the apk and loading it, the app crashes on start. If I build the aab and extract apks locally via bundletools
it works fine no crash. The error in logcat for the Google Play apk is
10-31 02:12:14.002 11662 11685 E SoLoader: couldn't find DSO to load: libhermes.so
10-31 02:12:14.002 11662 11685 E SoLoader: SoSource 0: com.facebook.soloader.ApkSoSource[root = /data/data/com.enfusion.mobile/lib-main flags = 1]
10-31 02:12:14.002 11662 11685 E SoLoader: SoSource 1: com.facebook.soloader.DirectorySoSource[root = /data/app/~~TTks-HIKZEo5VzxoDGnTHg==/com.enfusion.mobile-0pPe7Iv2Qbh6Vqk8GP2NCQ==/lib/x86 flags = 0]
10-31 02:12:14.002 11662 11685 E SoLoader: SoSource 2: com.facebook.soloader.DirectorySoSource[root = /vendor/lib flags = 2]
10-31 02:12:14.002 11662 11685 E SoLoader: SoSource 3: com.facebook.soloader.DirectorySoSource[root = /system/lib flags = 2]
10-31 02:12:14.002 11662 11685 E SoLoader: Native lib dir: /data/app/~~TTks-HIKZEo5VzxoDGnTHg==/com.enfusion.mobile-0pPe7Iv2Qbh6Vqk8GP2NCQ==/lib/x86
10-31 02:12:14.002 11662 11685 E SoLoader: result: 0
10-31 02:12:14.005 11662 11685 E AndroidRuntime: FATAL EXCEPTION: create_react_context
10-31 02:12:14.005 11662 11685 E AndroidRuntime: Process: com.enfusion.mobile, PID: 11662
10-31 02:12:14.005 11662 11685 E AndroidRuntime: java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libhermes.so
10-31 02:12:14.005 11662 11685 E AndroidRuntime: SoSource 0: com.facebook.soloader.ApkSoSource[root = /data/data/com.enfusion.mobile/lib-main flags = 1]
10-31 02:12:14.005 11662 11685 E AndroidRuntime: SoSource 1: com.facebook.soloader.DirectorySoSource[root = /data/app/~~TTks-HIKZEo5VzxoDGnTHg==/com.enfusion.mobile-0pPe7Iv2Qbh6Vqk8GP2NCQ==/lib/x86 flags = 0]
10-31 02:12:14.005 11662 11685 E AndroidRuntime: SoSource 2: com.facebook.soloader.DirectorySoSource[root = /vendor/lib flags = 2]
10-31 02:12:14.005 11662 11685 E AndroidRuntime: SoSource 3: com.facebook.soloader.DirectorySoSource[root = /system/lib flags = 2]
10-31 02:12:14.005 11662 11685 E AndroidRuntime: Native lib dir: /data/app/~~TTks-HIKZEo5VzxoDGnTHg==/com.enfusion.mobile-0pPe7Iv2Qbh6Vqk8GP2NCQ==/lib/x86
10-31 02:12:14.005 11662 11685 E AndroidRuntime: result: 0
10-31 02:12:14.005 11662 11685 E AndroidRuntime: at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:918)
10-31 02:12:14.005 11662 11685 E AndroidRuntime: at com.facebook.soloader.SoLoader.loadLibraryBySoNameImpl(SoLoader.java:740)
10-31 02:12:14.005 11662 11685 E AndroidRuntime: at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:654)
10-31 02:12:14.005 11662 11685 E AndroidRuntime: at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:634)
10-31 02:12:14.005 11662 11685 E AndroidRuntime: at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:582)
10-31 02:12:14.005 11662 11685 E AndroidRuntime: at com.facebook.hermes.reactexecutor.HermesExecutor.<clinit>(HermesExecutor.java:20)
10-31 02:12:14.005 11662 11685 E AndroidRuntime: at com.facebook.hermes.reactexecutor.HermesExecutorFactory.create(HermesExecutorFactory.java:29)
10-31 02:12:14.005 11662 11685 E AndroidRuntime: at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:1066)
10-31 02:12:14.005 11662 11685 E AndroidRuntime: at java.lang.Thread.run(Thread.java:923)
I have been able to repro this on multiple versions of react native. I have tested 0.64.2, 0.65.1 and 0.66.1 I have attached to script i have been using to test. I just create a new app make it match my app structure, add release signing, enable hermes and build the aab.
Version
0.66.1
Output of react-native info
System:
OS: macOS 12.0.1
CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 2.06 GB / 64.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 14.17.4 - /var/folders/dj/ct20rsf93m55bkxkq857yvl80000gp/T/yarn--1635665627163-0.7105097726381648/node
Yarn: 1.22.10 - /var/folders/dj/ct20rsf93m55bkxkq857yvl80000gp/T/yarn--1635665627163-0.7105097726381648/yarn
npm: 6.14.14 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.11.2 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.0.1, iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0
Android SDK:
API Levels: 27, 28, 29, 30, 31
Build Tools: 28.0.3, 29.0.2, 30.0.0, 30.0.1, 30.0.2, 30.0.3, 31.0.0, 31.0.0
System Images: android-29 | Google Play Intel x86 Atom, android-30 | Google APIs Intel x86 Atom, android-30 | Google Play Intel x86 Atom
Android NDK: Not Found
IDEs:
Android Studio: 2020.3 AI-203.7717.56.2031.7784292
Xcode: 13.1/13A1030d - /usr/bin/xcodebuild
Languages:
Java: 15.0.1 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 17.0.2 => 17.0.2
react-native: 0.66.1 => 0.66.1
react-native-macos: Not Found
npmGlobalPackages:
*react-native*: Not Found
Steps to reproduce
Create new react native app in this case typescript. Move to a com.test.mobile structure. Enable hermes. Add release signing. gradlew bundleRelease Upload aab to Google Play App bundle explorer Download apk Load on to android device in this case api 30 / android 11 App crashes on load
Snack, code example, screenshot, or link to a repository
#!/bin/bash
set -e
# Basic template create, setup, build
\rm -fr Test
echo "Testing react-native"
if ! which yarn > /dev/null 2>&1; then
echo "This script uses yarn, please install yarn (for example \`npm i yarn -g\` and re-try"
exit 1
fi
npx react-native init Test --version=0.64.2 --template react-native-template-typescript
cd Test
echo "Moving to com.test.mobile"
sed -i -e $'s/"com.test"/"com.test.mobile"/' android/app/_BUCK
rm -f android/app/_BUCK??
sed -i -e $'s/"com.test"/"com.test.mobile"/' android/app/build.gradle
rm -f android/app/build.gradle??
sed -i -e $'s/com.test/com.test.mobile/' android/app/src/debug/java/com/test/ReactNativeFlipper.java
rm -f android/app/src/debug/java/com/test/ReactNativeFlipper.java??
sed -i -e $'s/"com.test"/"com.test.mobile"/' android/app/src/main/AndroidManifest.xml
rm -f android/app/src/main/AndroidManifest.xml??
sed -i -e $'s/com.test;/com.test.mobile;/' android/app/src/main/java/com/test/MainActivity.java
rm -f android/app/src/main/java/com/test/MainActivity.java??
sed -i -e $'s/com.test;/com.test.mobile;/' android/app/src/main/java/com/test/MainApplication.java
sed -i -e $'s/com.test.R/com.test.mobile.R/' android/app/src/main/java/com/test/MainApplication.java
rm -f android/app/src/main/java/com/test/MainApplication.java??
mkdir -p ./android/app/src/main/java/com/test-temp/mobile
mv -v ./android/app/src/main/java/com/test/* ./android/app/src/main/java/com/test-temp/mobile/
rm -rf ./android/app/src/main/java/com/test/
mv ./android/app/src/main/java/com/test-temp ./android/app/src/main/java/com/test
mkdir -p ./android/app/src/debug/java/com/test-temp/mobile
mv -v ./android/app/src/debug/java/com/test/* ./android/app/src/debug/java/com/test-temp/mobile/
rm -rf ./android/app/src/debug/java/com/test/
mv ./android/app/src/debug/java/com/test-temp ./android/app/src/debug/java/com/test
echo "Setting up release build"
sed -i -e $'s/versionCode 1/versionCode 62/' android/app/build.gradle
rm -f android/app/build.gradle??
sed -i -e $'s/versionName "1.0"/versionName "1.7.0"/' android/app/build.gradle
rm -f android/app/build.gradle??
sed -i -e $'s/signingConfig signingConfigs.debug/signingConfig signingConfigs.release/' android/app/build.gradle
rm -f android/app/build.gradle??
sed -i -e "s/keyPassword 'android'/keyPassword 'android'\n }\n release {\n storeFile file(MYAPP_UPLOAD_STORE_FILE)\n storePassword MYAPP_UPLOAD_STORE_PASSWORD\n keyAlias MYAPP_UPLOAD_KEY_ALIAS\n keyPassword MYAPP_UPLOAD_KEY_PASSWORD/" android/app/build.gradle
rm -f android/app/build.gradle??
sed -i -e $'s/enableHermes: false/enableHermes: true/' android/app/build.gradle
rm -f android/app/build.gradle??
if [ -f "../test.jks" ]; then
cp ../test.jks android/app/
else
echo "Unable to locate the file 'test.jks'. Signing will fail."
exit 1
fi
echo "" >> ./android/gradle.properties
echo "MYAPP_UPLOAD_STORE_FILE=test.jks" >> ./android/gradle.properties
echo "MYAPP_UPLOAD_KEY_ALIAS=--" >> ./android/gradle.properties
echo "MYAPP_UPLOAD_STORE_PASSWORD=--" >> ./android/gradle.properties
echo "MYAPP_UPLOAD_KEY_PASSWORD=--" >> ./android/gradle.properties
# Another Java build tweak - or gradle runs out of memory during the build
echo "Increasing memory available to gradle for android java build"
echo "" >> ./android/gradle.properties
echo "org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8" >> android/gradle.properties
if [ "$(uname)" == "Darwin" ]; then
# workaround for poorly setup Android SDK environments
USER=$(whoami)
echo "sdk.dir=/Users/$USER/Library/Android/sdk" > android/local.properties
fi
cd android
./gradlew bundleRelease
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (11 by maintainers)
Top GitHub Comments
Yep sorry my bad. Yes tested locally via
bundletools
was tired when I added that should have added more infoNm probably google again I will close this. Interestingly if anyone wants to know the issue is with the per device apk not the universal apk that google generates Like here if I download the apk for the pixel 4 directly and load it I get the same error but if I download the universal one above its fine