React Native 0.62 Universal APK crashed on x86 CPU Android
See original GitHub issueDescription
I tried to build APK for Android after upgrading my project from 0.61.5 to 062, however the build universal APK crashed.
I then tried to built the APK on a fresh React Native 0.62 project and similar thing happens.
I tried the APK on several emulators. On emulators with x86 CPU it crashed but on x86_64 the APK can run without problem.
I don’t know if it is a bug in React Native or I somehow messed up my environments. I would appricate any help, thank you!
React Native version:
yarn run v1.22.4
$ D:\Codes\tryUniversalAPK\node_modules\.bin\react-native info
info Fetching system and libraries information...
System:
OS: Windows 10 10.0.18363
CPU: (12) x64 AMD Ryzen 5 2600 Six-Core Processor
Memory: 19.23 GB / 31.95 GB
Binaries:
Node: 13.11.0 - C:\Users\Indra\AppData\Local\Temp\yarn--1585793456760-0.2610294802603219\node.CMD
Yarn: 1.22.4 - C:\Users\Indra\AppData\Local\Temp\yarn--1585793456760-0.2610294802603219\yarn.CMD
npm: 6.13.7 - C:\Program Files\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK: Not Found
IDEs:
Android Studio: Version 3.6.0.0 AI-192.7142.36.36.6308749
Languages:
Python: 2.7.17 - C:\Python27\python.EXE
npmPackages:
@react-native-community/cli: Not Found
react: 16.11.0 => 16.11.0
react-native: 0.62.0 => 0.62.0
npmGlobalPackages:
*react-native*: Not Found
Done in 1.32s.
Steps To Reproduce
1 Initiate New Project
- Open terminal
npx react-native init tryUniversalAPK
cd tryUniversalAPK
2 Create an x86 CPU/ABI based emulator
- Open Android Virtual Device Manager
- Create virtual device with x86 CPU
- Launch the emulator
3 Build (crashed) and Native android log
- Open new terminal
adb logcat *:S ReactNative:V ReactNativeJS:V
- Open the terminal with
tryUniversalAPK
directory - run
yarn android --variant=release
- The app will crash
- Open the terminal with
adb logcat
running, it shows these errors--------- beginning of main --------- beginning of system 04-02 08:32:42.891 8782 8782 D ReactNative: ReactInstanceManager.ctor() 04-02 08:32:42.939 8782 8782 D ReactNative: ReactInstanceManager.createReactContextInBackground() 04-02 08:32:42.939 8782 8782 D ReactNative: ReactInstanceManager.recreateReactContextInBackgroundInner() 04-02 08:32:42.939 8782 8782 D ReactNative: ReactInstanceManager.recreateReactContextInBackgroundFromBundleLoader() 04-02 08:32:42.939 8782 8782 D ReactNative: ReactInstanceManager.recreateReactContextInBackground() 04-02 08:32:42.939 8782 8782 D ReactNative: ReactInstanceManager.runCreateReactContextOnNewThread() --------- beginning of crash 04-02 08:34:32.749 9021 9021 D ReactNative: ReactInstanceManager.ctor() 04-02 08:34:32.764 9021 9021 D ReactNative: ReactInstanceManager.createReactContextInBackground() 04-02 08:34:32.765 9021 9021 D ReactNative: ReactInstanceManager.recreateReactContextInBackgroundInner() 04-02 08:34:32.765 9021 9021 D ReactNative: ReactInstanceManager.recreateReactContextInBackgroundFromBundleLoader() 04-02 08:34:32.765 9021 9021 D ReactNative: ReactInstanceManager.recreateReactContextInBackground() 04-02 08:34:32.765 9021 9021 D ReactNative: ReactInstanceManager.runCreateReactContextOnNewThread()
4 Modify gradle to build APK on separate build per CPU architecture
- Open
tryUniversalAPK/android/app/build.gradle
- change
intodef enableSeparateBuildPerCPUArchitecture = false
def enableSeparateBuildPerCPUArchitecture = true
- change
intouniversalApk false
universalApk true
5 Rebuild
cd tryUniversalAPK/android
- run
./gradlew clean
cd ..
- run
yarn android --variant=release
- The app able to run without crash
- I noticed these in the terminal. The APK installed seems to be the
app-x86-release.apk
> Task :app:installRelease 08:58:13 V/ddms: execute: running am get-config 08:58:13 V/ddms: execute 'am get-config' on 'emulator-5554' : EOF hit. Read: -1 08:58:13 V/ddms: execute: returning Installing APK 'app-x86-release.apk' on 'Pixel_3_API_28(AVD) - 9' for app:release 08:58:13 D/app-x86-release.apk: Uploading app-x86-release.apk onto device 'emulator-5554' 08:58:13 D/Device: Uploading file onto device 'emulator-5554' 08:58:13 D/ddms: Reading file permision of D:\Codes\tryUniversalAPK\android\app\build\outputs\apk\release\app-x86-release.apk as: rwx------ 08:58:13 V/ddms: execute: running pm install -r -t "/data/local/tmp/app-x86-release.apk" 08:58:14 V/ddms: execute 'pm install -r -t "/data/local/tmp/app-x86-release.apk"' on 'emulator-5554' : EOF hit. Read: -1 08:58:14 V/ddms: execute: returning 08:58:14 V/ddms: execute: running rm "/data/local/tmp/app-x86-release.apk" 08:58:14 V/ddms: execute 'rm "/data/local/tmp/app-x86-release.apk"' on 'emulator-5554' : EOF hit. Read: -1 08:58:14 V/ddms: execute: returning Installed on 1 device.
6 Testing the built APKs
- Navigate to
tryUniversalAPK\android\app\build\outputs\apk\release
folder - There are five different APKs
- I uninstalled the
tryUniversalAPK
app in the android emulator - I drag and drop the
app-universal-release.apk
to the emulator - The app crashed
- Uninstalled the
tryUniversalAPK
app (this is theapp-universal-release.apk
) in the emulator - I drag and drop the
app-x86-release.apk
to the emulator - The app can run
Expected Results
The universl APK able to run without crash
ZIP file containing the built APKs
Issue Analytics
- State:
- Created 3 years ago
- Reactions:10
- Comments:20
Top Results From Across the Web
React Native universal apk crashes immediately
The generated app-armeabi-v7a-release works fine. But the universal apk crashes immediately. Here's the error it shows. java.lang.
Read more >Publishing to Google Play Store - React Native
Publishing to Google Play Store. Android requires that all apps be digitally signed with a certificate before they can be installed.
Read more >Pytorch not compatible with React-native library - Mobile
I've been using react native for one of my module.Recently we started using Pytorch . Pytorch along with react native is crashing.
Read more >How to Reduce React Native App Size? - Aglowid IT Solutions
For this blog, we decided to create the android apk and see which factors affect the size of apk and helped us Reduce...
Read more >App immediatly crash after installing react-native-webrtc - Help
Would be easier to debug if you could provide logs from logcat. Shouldn't be more than opening the android project in Android Studio,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I found a solution from here https://github.com/facebook/react-native/issues/25923#issuecomment-594047945
I added this piece of code in
android/app/build.gradle
and the app can run withyarn android --variant=release
and not crashing.tryUniversalAPK/android/app/build.gradle
fileOnly two lines were changed
def enableSeparateBuildPerCPUArchitecture = true
anduniversalApk true