til
AGP 4.1 `VERSION_NAME` changes
For as long as there has been Android, and Android libraries and apps, the Android Gradle Plugin would always generate the ANDROID_VERSION
and ANDROID_NAME
BuildConfig
fields during the compilation step.
With Android Studio 4.1 and the Android Gradle Plugin 4.1 (currently RC3) this is about to change for library projects.
Version Code mean nothing for Libraries. It's actually potentially confusing as one might expect that the BuildConfig.VERSION_NAME of a library is set to the version name of the app but this was never the case. For these reasons, it's better to not include it in library modules.
Android-IssueTracker
This change makes a lot of sense, but in some cases you still might want to expose the library version to customers integrating the app.
Luckily the buildConfigField
specification of your module's build.gradle
allows you to specify this again.
buildConfigField "String", "VERSION_NAME", "\"${versionName}\""
buildConfigField "int", "VERSION_CODE", "${versionCode}"