YoussefHenna / expo-enode-link-sdk

An Expo Module integration for Enode's Link SDK
MIT License
8 stars 2 forks source link

Android production build crashes on startup #12

Closed bjornevik closed 8 months ago

bjornevik commented 8 months ago

Hi i'm having a problem with android production builds building fine, but when running them on a device it crashes after the splash screen. I'm having the same problem when running android development builds with the --no-dev flag.

This only happens when I install this package, even if I don't use it, and I'm not able to recreate it with a clean create-expo-app project.

The initial error I'm shown is a Invariant Violation: "main" has not been registered^mainnotregistered error. The fatal error I'm getting when running with adb logcat is the following, which I believe is a red herring:

--------- beginning of crash
02-13 09:09:15.207  6076  6139 E AndroidRuntime: FATAL EXCEPTION: expo-updates-error-recovery
02-13 09:09:15.207  6076  6139 E AndroidRuntime: Process: no.my.app, PID: 6076
02-13 09:09:15.207  6076  6139 E AndroidRuntime: java.lang.RuntimeException: Could not invoke RNSentry.fetchNativeAppStart

Furthermore I also find the following error in adb logcat

2024-02-19 15:18:23.651 12792-12981 ReactNativeJS           app.app.app                   E  ReferenceError: Property 'viewManagersMetadata' doesn't exist, js engine: hermes
2024-02-19 15:18:23.653 12792-12981 ReactNativeJS           app.app.app                   E  Invariant Violation: "main" has not been registered. This can happen if:
                                                                                                    * Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
                                                                                                    * A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called., js engine: hermes

The only references to viewManagersMetadata I can find is in the following packages: expo-modules-core, expo-dev-menu, expo-dev-launcher. Seeing as expo-modules-core is the only dependency this package uses I'm guessing the problem is related to it, but once again, because it works fine on a clean create-expo-app project I don't know.

Also found a NullPointerException in adb logcat, but I'm suspecting it's related to the expo-updates red herring.

02-13 09:09:31.291  6222  6289 E ExpoModulesCore: Invalidated JavaCallback was invoked
02-13 09:09:31.291  6222  6289 E ExpoModulesCore: java.lang.NullPointerException: java.lang.NullPointerException
02-13 09:09:31.291  6222  6289 E ExpoModulesCore:       at expo.modules.kotlin.jni.JavaCallback.invoke(Native Method)
02-13 09:09:31.291  6222  6289 E ExpoModulesCore:       at expo.modules.kotlin.jni.JavaCallback.invoke(JavaCallback.kt:26)
02-13 09:09:31.291  6222  6289 E ExpoModulesCore:       at expo.modules.kotlin.jni.PromiseImpl.reject(PromiseImpl.kt:95)
02-13 09:09:31.291  6222  6289 E ExpoModulesCore:       at expo.modules.kotlin.PromiseKt$toBridgePromise$1.reject(Promise.kt:45)
02-13 09:09:31.291  6222  6289 E ExpoModulesCore:       at expo.modules.kotlin.KPromiseWrapper.reject(KPromiseWrapper.kt:17)
02-13 09:09:31.291  6222  6289 E ExpoModulesCore:       at expo.modules.updates.UpdatesModule$definition$1$4$1.onSuccess(UpdatesModule.kt:121)

I'm at wits end, the only idea I have is to upgrade the expo-modules-core dependency in this project, but I logically don't see how that would help when it runs fine on a clean create-expo-app project.

Any ideas? I've been stuck with this for a week.

YoussefHenna commented 8 months ago

It's possible that one or more of the other packages you have installed is conflicting with this one, which could be an explanation for why it works on a clean app and not on yours. You could try a resolution for expo-modules-core and see if that addresses it. If not, then if you can include a minimal reproducible example I can investigate it some more.

bjornevik commented 8 months ago

Finally made some progress, seems like the RNSentry.fetchNativeAppStart wasn't a red herring after all. It seems to be working after removing @sentry/react-native and sentry-expo.

Seeing as sentry-expo has been merged into @sentry/react-native and been deprecated as of SDK 50, that might be the problem. I'll keep troubleshooting - hopefully I'll be able to pinpoint the issue.

bjornevik commented 8 months ago

The crash only happens if I set the tracesSampleRate parameter in the Sentry.Init({ /* ... */}) call. Unsure why. Nonetheless seems like it's a Sentry issue and not a issue with this package. I've opened an issue in the sentry-react-native repo, and I'll close this issue since I got it working.