getsentry / sentry-react-native

Official Sentry SDK for React Native
https://sentry.io
MIT License
1.58k stars 338 forks source link

Android app is crashing on production after installing sentry #779

Closed itsyogesh closed 4 years ago

itsyogesh commented 4 years ago

OS:

Platform:

SDK:

SDK version: 1.3.2 react-native version: 0.61.5

Init Code:

Sentry.init({
  dsn: 'https://...@sentry.io/...'
});

I have following issue: Android is crashing on production, while it works fine on the debug. I am getting the following issue. Description goes here ... Running the app on production is causing the following issue. Screenshot_2020-02-24-09-40-48-763_com miui bugreport

Steps to reproduce:

Actual result: The app is crashing as soon as its opened.

Expected result: It should run normally after installing the app.

itsyogesh commented 4 years ago

I tried setting up android as described here, https://sentry.io/for/android/ but it wasn't working. Had to downgrade to 1.2.1 and it's working fine now.

xwartz commented 4 years ago

I have the same issue when upgraded the version from 1.3.1 to 1.3.2.

02-26 13:50:32.765 15372 15794 I im.token.app.c: (Throwable with no stack trace)
02-26 13:50:32.765 15372 15794 I im.token.app.c:
02-26 13:50:32.768 15372 15794 E unknown:ReactNative: Exception in native call
02-26 13:50:32.768 15372 15794 E unknown:ReactNative: java.lang.RuntimeException: Could not invoke RNSentry.startWithDsnString
02-26 13:50:32.768 15372 15794 E unknown:ReactNative:   at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:383)
02-26 13:50:32.768 15372 15794 E unknown:ReactNative:   at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:158)
02-26 13:50:32.768 15372 15794 E unknown:ReactNative:   at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
02-26 13:50:32.768 15372 15794 E unknown:ReactNative:   at android.os.Handler.handleCallback(Handler.java:883)
02-26 13:50:32.768 15372 15794 E unknown:ReactNative:   at android.os.Handler.dispatchMessage(Handler.java:100)
02-26 13:50:32.768 15372 15794 E unknown:ReactNative:   at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
02-26 13:50:32.768 15372 15794 E unknown:ReactNative:   at android.os.Looper.loop(Looper.java:214)
02-26 13:50:32.768 15372 15794 E unknown:ReactNative:   at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:232)
02-26 13:50:32.768 15372 15794 E unknown:ReactNative:   at java.lang.Thread.run(Thread.java:919)
02-26 13:50:32.768 15372 15794 E unknown:ReactNative: Caused by: java.lang.reflect.InvocationTargetException
02-26 13:50:32.768 15372 15794 E unknown:ReactNative:   at java.lang.reflect.Method.invoke(Native Method)
02-26 13:50:32.768 15372 15794 E unknown:ReactNative:   at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
02-26 13:50:32.768 15372 15794 E unknown:ReactNative:   ... 8 more
02-26 13:50:32.768 15372 15794 E unknown:ReactNative: Caused by: java.lang.NoClassDefFoundError: io.sentry.android.ndk.SentryNdk
02-26 13:50:32.768 15372 15794 E unknown:ReactNative:   at java.lang.Class.classForName(Native Method)
02-26 13:50:32.768 15372 15794 E unknown:ReactNative:   at java.lang.Class.forName(Class.java:454)
02-26 13:50:32.768 15372 15794 E unknown:ReactNative:   at java.lang.Class.forName(Class.java:379)
02-26 13:50:32.768 15372 15794 E unknown:ReactNative:   at io.sentry.android.core.NdkIntegration.register(NdkIntegration.java:26)
02-26 13:50:32.768 15372 15794 E unknown:ReactNative:   at io.sentry.core.Hub.<init>(Hub.java:35)
02-26 13:50:32.768 15372 15794 E unknown:ReactNative:   at io.sentry.core.Sentry.init(Sentry.java:143)
02-26 13:50:32.768 15372 15794 E unknown:ReactNative:   at io.sentry.core.Sentry.init(Sentry.java:91)
02-26 13:50:32.768 15372 15794 E unknown:ReactNative:   at io.sentry.android.core.SentryAndroid.init(SentryAndroid.java:59)
02-26 13:50:32.768 15372 15794 E unknown:ReactNative:   at io.sentry.android.core.SentryAndroid.init(SentryAndroid.java:44)
02-26 13:50:32.768 15372 15794 E unknown:ReactNative:   at io.sentry.RNSentryModule.startWithDsnString(RNSentryModule.java:66)
02-26 13:50:32.768 15372 15794 E unknown:ReactNative:   ... 10 more
02-26 13:50:32.768 15372 15794 E unknown:ReactNative: Caused by: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/im.token.app.cn-iGx97_rZ_Ajvhs9mVYFSAg==/base.apk"],nativeLibraryDirectories=[/data/app/im.token.app.cn-iGx97_rZ_Ajvhs9mVYFSAg==/lib/x86, /data/app/im.token.app.cn-iGx97_rZ_Ajvhs9mVYFSAg==/base.apk!/lib/x86, /system/lib, /system/product/lib]]] couldn't find "libsentry.so"
02-26 13:50:32.768 15372 15794 E unknown:ReactNative:   at java.lang.Runtime.loadLibrary0(Runtime.java:1067)
02-26 13:50:32.768 15372 15794 E unknown:ReactNative:   at java.lang.Runtime.loadLibrary0(Runtime.java:1007)
02-26 13:50:32.768 15372 15794 E unknown:ReactNative:   at java.lang.System.loadLibrary(System.java:1667)
02-26 13:50:32.768 15372 15794 E unknown:ReactNative:   at io.sentry.android.ndk.SentryNdk.<clinit>(SentryNdk.java:12)
02-26 13:50:32.768 15372 15794 E unknown:ReactNative:   ... 20 more
02-26 13:50:32.970 15372 15794 I Intercom: registerUnidentifiedUser
xwartz commented 4 years ago

cc @HazAT

marandaneto commented 4 years ago

@itsyogesh hey, thanks for raising this issue.

if you just run npx react-native run-android --variant=release do you get the same issue?

I've tried using RN 0.61.5 and Sentry 1.3.3 and it works fine. Could you test it using 1.3.3, please? thanks :)

marandaneto commented 4 years ago

@itsyogesh also, the link you should be looking into is https://docs.sentry.io/platforms/react-native/ this link already sets up sentry-android and sentry-cocoa under the hood for you, that might be the problem.

Could you give it a try? thanks.

marandaneto commented 4 years ago

hey, @xwartz your issue seems to be different, to be honest. It's like it didn't do the packaging correctly.

Could you try: cd android; ./gradlew clean cleanBuildCache just to clean the gradle caching. and npx react-native run-android to run via react-native CLI.

Also, have you followed the same steps here? https://docs.sentry.io/platforms/react-native/ What's your RN and sentry-react-native versions? thanks.

xwartz commented 4 years ago

@marandaneto thanks, it works for me

HazAT commented 4 years ago

Closing this since @marandaneto provided the correct answer.

httpiga commented 4 years ago

I had the same issue and cd android; ./gradlew clean cleanBuildCache resolved it but I suggest to add this line to the docs https://docs.sentry.io/platforms/react-native/