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

Prevent exception when old Moshi version on buildScript classpath #439

Closed fractalwrench closed 3 years ago

fractalwrench commented 3 years ago

Goal

v5.8.0 added default values in these constructor parameters, which compiled to bytecode results in two constructors. This results in Moshi generating a slightly different JsonAdapter class, which needs to use the DEFAULT_CONSTRUCTOR_MARKER field to try and find the correct ctor.

If a user has a plugin in the buildscript classpath which has a dependency on an old version of Moshi (<1.9.1) then the DEFAULT_CONSTRUCTOR_MARKER is not present, resulting in a NoSuchFieldError being thrown.

This fixes the issue by avoiding the use of default parameters. The end-user should also update any plugins using an old version of Moshi.

Testing

Manually verified in an example app.