Back
If you're working the Gradle plugin/Android Studio, as of version 0.7.0, version code and version name are accessible statically in BuildConfig. Get sure you ship your app's package and not extra BuildConfig:
import com.yourpackage.BuildConfig;...int versionCode = BuildConfig.VERSION_CODE;String versionName = BuildConfig.VERSION_NAME;
import com.yourpackage.BuildConfig;
...
int versionCode = BuildConfig.VERSION_CODE;
String versionName = BuildConfig.VERSION_NAME;
No Setting object required!
Also, secure to define them in your build.gradle file rather of the AndroidManifest.xml.
defaultConfig {versionCode 1versionName "1.0"}
defaultConfig {
versionCode 1
versionName "1.0"
}
31k questions
32.8k answers
501 comments
693 users