Android app using `r8` crashes on `SentrySdk.Init`
See original GitHub issuePackage
Sentry
.NET Flavor
.NET
.NET Version
6.0.0
OS
Android
SDK Version
7.0.203
Self-Hosted Sentry Version
No response
Steps to Reproduce
- Clone the Android Sample
- Enable
r8
tooling
<AndroidLinkTool>r8</AndroidLinkTool>
- Deploy
Expected Result
Successful initialization
Actual Result
Java.Lang.NoSuchMethodError
Message
no static method "Lio/sentry/android/core/SentryAndroid;.init(Landroid/content/Context;Lio/sentry/Sentry$OptionsConfiguration;)V"
CallStack
0xFFFFFFFFFFFFFFFF in Android.Runtime.JNIEnv.monodroid_debugger_unhandled_exception
0x1A in Android.Runtime.JNINativeWrapper._unhandled_exception at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:12,5
0x1E in Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPL_V at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:122,26
0x17 in System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw
0x5B in Java.Interop.JniEnvironment.StaticMethods.GetStaticMethodID at /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/Java.Interop/JniEnvironment.g.cs:12847,5
0xE in Java.Interop.JniType.GetStaticMethod at /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/Java.Interop/JniType.cs:256,4
0x39 in Java.Interop.JniPeerMembers.JniStaticMethods.GetMethodInfo at /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniStaticMethods.cs:31,6
0x2 in Java.Interop.JniPeerMembers.JniStaticMethods.InvokeVoidMethod at /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniStaticMethods.cs:40,4
0x5E in Sentry.JavaSdk.Android.Core.SentryAndroid.Init
0xB9 in Sentry.SentrySdk.InitSentryAndroidSdk
0x61 in Sentry.SentrySdk.InitHub
0x1 in Sentry.SentrySdk.Init
0x11 in Sentry.SentrySdk.Init
0x174 in Sentry.Samples.Android.MainActivity.OnCreate at D:\Programmieren\Visual Studio Projects\Sentry-Android\samples\Sentry.Samples.Android\MainActivity.cs:65,5
at D:\Programmieren\Visual Studio Projects\Sentry-Android\samples\Sentry.Samples.Android\MainActivity.cs(65)
0x11 in Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/net6.0/android-31/mcw/Android.App.Activity.cs:2781,4
0x9 in Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPL_V at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:121,5
Issue Analytics
- State:
- Created 4 months ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Enabling R8 crashes application - android
So I enabled R8 in my project by adding android.enableR8=true to gradle.properties. This is my gradle file: buildTypes { release { useProguard ...
Read more >Enabling R8 crashes application [167913510] - Issue Tracker
I tried to migrate to Proguard by setting android.enableR8=false to gradle.properties and useProguard true in Gradle file, and the app worked fine without ......
Read more >Sentry SDK for Flutter - Flutter Packages
This package includes support to native crashes through Sentry's native SDKs: (Android and iOS). It will capture errors in the native layer, ...
Read more >App crashes on startup when R8 shrinker is set in Maui
Application crashes in startup when I set the R8 shrinker in release mode and use the secure storage in application. android.runtime.
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 FreeTop 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
Top GitHub Comments
Hey @ShortDevelopment, I can reproduce the issue locally. A fix will be coming shortly.
The issue is that shrinking/obfuscating changes the method names the SDK is looking for. We’re going to make that work out of the box but as a workaround to unblock yourself immediately: You can add the following to the
proguard.cfg
: