getsentry / sentry-android-gradle-plugin

Gradle plugin for Sentry Android. Upload proguard, debug files, and more.
https://docs.sentry.io/platforms/android/gradle/
MIT License
143 stars 33 forks source link

Sentry Plugin is causing the application to crash #315

Closed dorukkangal closed 2 years ago

dorukkangal commented 2 years ago

Gradle Version

7.4.2

AGP Version

7.1.2

Code Minifier/Optimizer

Proguard

Version

3.0.0

Sentry SDK Version

5.7.1

Description

We are using Braze library in our application and it works fine. If we apply Sentry plugin, the application crashes when opening.

Steps to Reproduce

You can reproduce the error with the repository given below: https://github.com/dorukkangal/braze-sample

The error doesn't occur again when I disable tracingInstrumentation. I think the bytecode manipulation is causing VerifyError.

Log

java.lang.VerifyError: Verifier rejected class com.braze.support.BrazeImageUtils: android.graphics.Bitmap com.braze.support.BrazeImageUtils.getLocalBitmap(android.net.Uri, int, int) failed to verify: android.graphics.Bitmap com.braze.support.BrazeImageUtils.getLocalBitmap(android.net.Uri, int, int): [0x75] register v6 has type Precise Reference: java.lang.String but expected Reference: java.io.FileInputStream (declaration of 'com.braze.support.BrazeImageUtils' appears in /data/app/~~mudJ3b4VR55TXuQMIoS8ew==/com.hepsiburada.merchant.qa-oFX-w_fRWgtmWrKbDRq6yg==/base.apk)
        at com.braze.support.BrazeImageUtils.getImageLoaderCacheSize(SourceFile:1)
        at com.braze.images.DefaultBrazeImageLoader.<init>(SourceFile:4)
        at com.appboy.Appboy.<init>(SourceFile:59)
        at com.braze.Braze.<init>(SourceFile:1)
        at com.appboy.Appboy.getInstance(SourceFile:7)
        at com.hepsiburada.merchant.di.AppModule.provideBraze(AppModule.kt:46)
        at com.hepsiburada.merchant.di.AppModule_ProvideBrazeFactory.provideBraze(AppModule_ProvideBrazeFactory.java:41)
        at com.hepsiburada.merchant.core.DaggerApp_HiltComponents_SingletonC$SwitchingProvider.get0(DaggerApp_HiltComponents_SingletonC.java:2011)
        at com.hepsiburada.merchant.core.DaggerApp_HiltComponents_SingletonC$SwitchingProvider.get(DaggerApp_HiltComponents_SingletonC.java:2354)
        at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
        at com.hepsiburada.merchant.core.DaggerApp_HiltComponents_SingletonC$SwitchingProvider.get0(DaggerApp_HiltComponents_SingletonC.java:2008)
        at com.hepsiburada.merchant.core.DaggerApp_HiltComponents_SingletonC$SwitchingProvider.get(DaggerApp_HiltComponents_SingletonC.java:2354)
        at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
        at com.hepsiburada.merchant.core.DaggerApp_HiltComponents_SingletonC$SwitchingProvider.get0(DaggerApp_HiltComponents_SingletonC.java:1993)
        at com.hepsiburada.merchant.core.DaggerApp_HiltComponents_SingletonC$SwitchingProvider.get(DaggerApp_HiltComponents_SingletonC.java:2354)
        at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
        at com.hepsiburada.merchant.core.DaggerApp_HiltComponents_SingletonC$ActivityCImpl.injectMainActivity2(DaggerApp_HiltComponents_SingletonC.java:1506)
        at com.hepsiburada.merchant.core.DaggerApp_HiltComponents_SingletonC$ActivityCImpl.injectMainActivity(DaggerApp_HiltComponents_SingletonC.java:1474)
        at com.hepsiburada.merchant.ui.Hilt_MainActivity.inject(Hilt_MainActivity.java:66)
        at com.hepsiburada.merchant.ui.Hilt_MainActivity$1.onContextAvailable(Hilt_MainActivity.java:37)
        at androidx.activity.contextaware.ContextAwareHelper.dispatchOnContextAvailable(ContextAwareHelper.java:99)
        at androidx.activity.ComponentActivity.onCreate(ComponentActivity.java:313)
        at androidx.fragment.app.FragmentActivity.onCreate(FragmentActivity.java:249)
        at com.hepsiburada.merchant.utils.base.BaseActivity.onCreate(BaseActivity.kt:30)
        at com.hepsiburada.merchant.ui.MainActivity.onCreate(MainActivity.kt:69)
        at android.app.Activity.performCreate(Activity.java:8054)
        at android.app.Activity.performCreate(Activity.java:8034)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1341)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3666)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3842)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2252)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loopOnce(Looper.java:201)
        at android.os.Looper.loop(Looper.java:288)
        at android.app.ActivityThread.main(ActivityThread.java:7842)
        at java.lang.reflect.Method.invoke(Native Method)
romtsn commented 2 years ago

Hey, thanks for the report and sorry for the troubles caused by the plugin. This indeed looks like an issue in our instrumentation. I will try to look into this next week.

Out of curiosity, do you actually use performance product (i.e. are you interested in the auto-instrumentation of file i/o or db queries at all)?

dorukkangal commented 2 years ago

Hi @romtsn,

Thanks for your response. We are currently using New Relic for performance monitoring. But we are considering switching to sentry.

romtsn commented 2 years ago

@dorukkangal could you please try the version 3.1.0-beta.2? I've tested with the braze library, but just to make sure it works :)

dorukkangal commented 2 years ago

Hi @romtsn, I have just tried it and it works. Thank you for your help.