bugsnag / bugsnag-android-gradle-plugin

Gradle plugin for BugSnag which uploads ProGuard, DexGuard and NDK mapping files, and sends build notifications
https://docs.bugsnag.com/build-integrations/gradle/
MIT License
70 stars 38 forks source link

Upload JVM Mapping not working with Proguard 7 plugin on Android #463

Open peterdk opened 2 years ago

peterdk commented 2 years ago

I am testing out the 7.x variant of Bugsnag for use with the new Android Gradle plugin. I get everything to work, except for uploading JVM mappings in combination with Proguard 7 Gradle plugin. Somehow it doesn't detect that mappings are available. I think it's because the new Proguard needs 'minifyEnabled' set to false.

I also tried uploading a mapping manually, but it says: 'uploadBugsnagReleaseMapping' not found in project ':project'. Some candidates are: 'uploadBugsnagNdkReleaseMapping'.

My config:

 bugsnag {
                uploadJvmMappings = true
                uploadNdkMappings = true
                overwrite = true
                sharedObjectPaths = [new File("../debugSOs/obj")]

            }

Am I missing something here? Can I use a workaround?

peterdk commented 2 years ago

It seems that this line in the gradle plugin causes the issue:

private fun Project.isJvmMinificationEnabled(variant: BaseVariant) =
        variant.buildType.isMinifyEnabled || hasDexguardPlugin()
luke-belton commented 2 years ago

Hi @peterdk - we're aware of some issues with the latest version of the Android Gradle Plugin, e.g. https://github.com/bugsnag/bugsnag-android-gradle-plugin/issues/462. Could you let us know what versions you're using of the following please?

peterdk commented 2 years ago

To give some more context: Proguard is the default implementation for minify in Android, but since Android Gradle 7 or so it now defaults to r8, and no longer can use proguard itself out of the box. Since I need proguard optimization for app performance (tests with r8 lead to less performant app) I added the proguard 'com.guardsquare:proguard-gradle:7.x plugin, which allows for using proguard with the newer AGP. However, this plugin requires minify to be false, since r8 needs to be disabled. Result is that bugsnag does not see that isJvmMinificationEnabled is true, since the logic doesn't know anything about this proguard plugin and sees minify set to false. It would be useful if bugsnag detects proguard and enabled the jvm upload, just like it also detects dexguard case. And in the case of proguard it's probably much easier to detect.

johnkiely1 commented 2 years ago

Hi @peterdk ,

Thanks for raising this. It does look like a use case we don't currently support for automatic uploads. We are going to look to get this fixed as soon as we can.

In the meantime as a work around you could look to manually upload the mapping.txt files which the Proguard plugin would generate with each build: https://docs.bugsnag.com/api/android-mapping-upload/#for-proguard