bugsnag-js icon indicating copy to clipboard operation
bugsnag-js copied to clipboard

Building React Native 0.73.1 causes Android app to crash with ProGuard enabled

Open swrobel opened this issue 1 year ago • 7 comments

Describe the bug

I recently upgraded my React Native app to 0.73.1. I have always built with ProGuard enabled for release versions without issues, but since upgrading to 0.73.1 from 0.72.7, I now get a crash:

Nothing has changed with my config; I simply followed the React Native upgrade helper. Disabling ProGuard fixes the crashes, although I'd like to get this resolved so that I can re-enable it, as my app download size has gone up almost 40% with ProGuard disabled.

Steps to reproduce

No idea if there's a simple repro for this. I don't actually have an Android device to test on, so I found out about the crash from one of my testers, and from the Bugsnag report. I guess this means it's still reporting to Bugsnag in some cases, so I'm not sure exactly what's broken...

Environment

  • Bugsnag version: 7.22.2
  • React Native 0.73.1
  • Device: Pixel 6 Pro, Android 12
Error messages:
com.facebook.react.common.JavascriptException: Error: No Bugsnag API Key set, js engine: hermes, stack:
_configure@1:684887
Client@1:684148
_createClient@1:661352
createClient@1:661182
start@1:661944
anonymous@1:82247
loadModuleImplementation@1:75876
guardedLoadModule@1:75375
metroRequire@1:75040
global@1:74592

        at com.facebook.react.modules.core.ExceptionsManagerModule.reportException(SourceFile:76)
        at java.lang.reflect.Method.invoke(Method.java:-2)
        at com.facebook.react.bridge.JavaMethodWrapper.invoke(SourceFile:147)
        at com.facebook.react.bridge.JavaModuleWrapper.invoke(SourceFile:22)
        at com.facebook.jni.NativeRunnable.run(SourceFile:-2)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(SourceFile:1)
        at android.os.Looper.loop(Looper.java:246)
        at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(SourceFile:38)
        at java.lang.Thread.run(Thread.java:923)

swrobel avatar Dec 27 '23 02:12 swrobel

Hi @swrobel I have created a reproduction application using the environment information you have provided and have been able to implement BugSnag with minifyEnabled true. As such I do not believe that this is due to an incompatibility error.

Rather, based off of the error message you are receiving, it would appear that the BugSnag API key has not been correctly set. You can configure this API key in your AndroidManifest.xml in the application tag. i.e.

<application ...>
  <meta-data android:name="com.bugsnag.android.API_KEY"
             android:value="your-api-key-here"/>
</application>

You can read more about setting this api key here in our documentation.

If after configuring the API key and your application is still producing the same error then please let us know and we can investigate this issue further.

clr182 avatar Jan 04 '24 12:01 clr182

If after configuring the API key and your application is still producing the same error then please let us know and we can investigate this issue further.

I have this key in my AndroidManifest.xml and have had it there for years, and it was working fine until upgrading, as I mentioned:

<meta-data android:name="com.bugsnag.android.API_KEY" android:value="my-key" />

Did you install & launch the app on a real device to test for the crash? When you generated a RN 0.73 project, did you get Kotlin files instead of Java, ex: MainApplication.kt?

swrobel avatar Jan 04 '24 23:01 swrobel

Same here

denis-rift avatar Jan 05 '24 09:01 denis-rift

Hi @swrobel

Would you mind sharing your build.gradle files so we may better understand the configuration of your application?

I you would prefer to not share these publicly then please feel free to open a support ticket with us by reaching out to us at [email protected], quoting this github issue (#2060) and attaching the files to the message.

clr182 avatar Jan 05 '24 11:01 clr182

@clr182 I just submitted them via email, ticket #66817. It's worth noting that my release config previously had minifyEnabled true, before I had to change it due to the crash.

swrobel avatar Jan 05 '24 18:01 swrobel

Hi @swrobel
Thank you for sharing these files via zendesk. To update you, we have been able to reproduce this issue and we are investigating this further. We will be sure to let you know once we have more information to share.

clr182 avatar Jan 08 '24 09:01 clr182

Hi @swrobel, thanks for reporting this.

React Native 0.73 bumps AGP to 8+ and it looks like this has changed some of the R8 optimisations, meaning the native plugin class used by the SDK is now being obfuscated.

We'll look to get this fixed in an upcoming release, but in the meantime you can add the following rule to android/app/proguard-rules.pro as a workaround:

-keep class com.bugsnag.android.BugsnagReactNativePlugin { *; }

yousif-bugsnag avatar Jan 15 '24 13:01 yousif-bugsnag

Hi :wave:

A fix for this issue has been released in version 7.22.4 of the BugSnag JS notifier.

After updating, please let us know whether you are seeing any further issues.

clr182 avatar Feb 29 '24 16:02 clr182