Android Gradle Plugin 4.0.0 までは library module にも生えていた BuildConfig.VERSION_CODE
と BuildConfig.VERSION_NAME
が 4.1.0-alpha05 から生えなくなってた
issuetracker: https://issuetracker.google.com/issues/154275579
Library module にとっては不要でしょ、とのこと
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.
AGP 4.1.0-beta01 で試しても同様だった
現在 library module の build.gradle
に versionCode
や versionName
を設定して、その module の BuildConfig
からバージョン情報にアクセスしているようなアプリはDIでバージョン情報を使うもの/取得できるものを app から配るようにしないとダメそう
追記 (2020-10-13)
4.1.0 stable 出ました
https://developer.android.com/studio/releases/gradle-plugin?buildsystem=ndk-build#4-1-0
記述はないけど上記のままっぽいです 書いてあったわ
アプリの構造や設計によってやりようは色々ですが、大雑把には
- DI で app module の
BuildConfig
へのプロキシを配る - 自分のアプリの PackageInfo から取得する
buildConfigField
でバージョン情報を設定する
辺りになるんじゃないでしょうか