question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Android app using `r8` crashes on `SentrySdk.Init`

See original GitHub issue

Package

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

  1. Clone the Android Sample
  2. Enable r8 tooling
<AndroidLinkTool>r8</AndroidLinkTool>
  1. 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:closed
  • Created 4 months ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
bitsandfoxescommented, Jun 23, 2023

Hey @ShortDevelopment, I can reproduce the issue locally. A fix will be coming shortly.

1reaction
bitsandfoxescommented, Jun 23, 2023

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 theproguard.cfg:

-keep public class io.sentry.** {
public protected private *;
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting for Android
Troubleshoot and resolve common issues with the Android SDK.
Read more >
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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found