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

Reject versionCodeOverride being used with VERSION_CODE meta-data #425

Closed lemnik closed 3 years ago

lemnik commented 3 years ago

Goal

The Android Gradle Plugin allows each application variant to have it's own versionCode and versionName, while Bugsnag also allows versionCode overriding using an AndroidManifest.xml meta-data attribute (com.bugsnag.android.VERSION_CODE). Using these two attributes together causes unexpected behaviour, with the source-maps being uploaded with one version and reports generated with a different version.

When detecting both a versionCodeOverride and com.bugsnag.android.VERSION_CODE in the same project we will now emit an error explaining that they should not be used together.

Design

The default versionCode / versionName attributes are tracked separately to those provided in meta-data attributes, and the final version details for a variant output are determined by a new AndroidManifestInfo.forApkVariantOutput function. This logic has been lifted into the BugsnagPlugin and the tasks requiring the version details receive their final AndroidManifestInfo by way of a mapped Provider.

Testing

New unit tests and end-to-end tests.