Android app crash after calling codepush.restart()
How frequently does the bug occur?
Always
Description
Same as https://github.com/realm/realm-js/issues/6903;
Stacktrace & log output
FATAL EXCEPTION: mqt_native_modules
Process:
java.lang.UnsatisfiedLinkError: No implementation found for void io.realm.react.RealmReactModule.invalidateCaches() (tried Java_io_realm_react_RealmReactModule_invalidateCaches and Java_io_realm_react_RealmReactModule_invalidateCaches__)
at io.realm.react.RealmReactModule.invalidateCaches(Native Method)
at io.realm.react.RealmReactModule.invalidate(RealmReactModule.java:58)
at com.facebook.react.bridge.ModuleHolder.destroy(ModuleHolder.java:109)
at com.facebook.react.bridge.NativeModuleRegistry.notifyJSInstanceDestroy(NativeModuleRegistry.java:86)
at com.facebook.react.bridge.CatalystInstanceImpl.lambda$destroy$2(CatalystInstanceImpl.java:366)
at com.facebook.react.bridge.CatalystInstanceImpl.$r8$lambda$Oa3wfVCkSpv9UbaDKR-owki1vUU(Unknown Source:0)
at com.facebook.react.bridge.CatalystInstanceImpl$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)
at android.os.Handler.handleCallback(Handler.java:900)
at android.os.Handler.dispatchMessage(Handler.java:103)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
at android.os.Looper.loop(Looper.java:219)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl.lambda$startNewBackgroundThread$2(MessageQueueThreadImpl.java:217)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$$ExternalSyntheticLambda1.run(D8$$SyntheticClass:0)
at java.lang.Thread.run(Thread.java:929)
Can you reproduce the bug?
Always
Reproduction Steps
- Integrate realm-js v20.1.0
- Integrate react-native-code-push
- Calling CodePush.restartApp();
Version
20.1.0
What services are you using?
Local Database only
Are you using encryption?
No
Platform OS and version(s)
Android,
Build environment
No response
Cocoapods version
No response
Anyone can help on this issue ?
+1
I found the root cause of this issue is that we don't initialize the realm library on the start of the app , we initialize it when certain module is loaded. it will crash if the realm is not initialized yet , else won't. So i add a workaround like this
@Override
public void invalidate() {
try {
invalidateCaches();
}catch (UnsatisfiedLinkError e){
Log.e("Realm",e.toString());
}
}
Basically just added a try catch to prevent the app crash, and it won't damage the function since if the realm is not initialized , there is no need to clear caches.
+1 experiencing this on Android only as well - the number of crashes seems to be correlated with the number of failed installs after downloads
Using Revopush as a provider ( fork of AppCenter Codepush )