My Android react native is working fine for debug builds, but after building the signed release apk with: cd android && ./gradlew assembleRelease then it always crashes on startup. The file size of the APK looks pretty similar to the debug one (not a huge difference). Here is the error from logcat. (I have checked the other stackoverflow issues on release ask problems but could not find a solution. I have also tried 'gradle clean' build).
React-native version 0.44
01-17 14:08:13.694 E/UncaughtException: java.lang.RuntimeException: Error calling AppRegistry.runApplication
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
at android.os.Looper.loop(Looper.java:154)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:208)
at java.lang.Thread.run(Thread.java:762)
Caused by: com.facebook.jni.CppException: Could not get BatchedBridge, make sure your bundle is packaged correctly
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
at android.os.Looper.loop(Looper.java:154)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:208)
at java.lang.Thread.run(Thread.java:762)
01-17 14:08:13.922 E/AndroidRuntime: FATAL EXCEPTION: mqt_js
Process: com.challengesolutions.lifeapp, PID: 9250
java.lang.RuntimeException: Error calling AppRegistry.runApplication
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
at android.os.Looper.loop(Looper.java:154)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:208)
at java.lang.Thread.run(Thread.java:762)
Caused by: com.facebook.jni.CppException: Could not get BatchedBridge, make sure your bundle is packaged correctly
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
at android.os.Looper.loop(Looper.java:154)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:208)
at java.lang.Thread.run(Thread.java:762)
Thanks for the help!
It looks like the issue is caused by a problem with the React Native bundle that is included in the release APK. The error message "Could not get BatchedBridge, make sure your bundle is packaged correctly" suggests that there might be a problem with the way the bundle is being packaged or loaded.
There are a few potential issues that might cause this error:
The bundle might not be correctly included in the APK. Make sure that the index.android.bundle file is correctly added to the assets folder in the Android project, and that the build process is correctly packaging the bundle in the APK.
The bundle might be corrupt or incomplete. Try running react-native bundle to rebuild the bundle, and make sure that the entire bundle is included in the APK.
The bundle might be incompatible with the version of React Native that is being used. Make sure that the version of React Native in your app matches the version of the bundle that is being included in the APK.
There might be a problem with the way the bundle is being loaded on the device. Try adding the following code to your app to log any errors that occur when the bundle is being loaded:
import { AppRegistry } from 'react-native'; AppRegistry.setLogger(logger => { logger.log = console.log.bind(console); logger.warn = console.warn.bind(console); logger.error = console.