Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (3.4k points)
I need to figure out how to get or make a build number for my Android application. I need the build number to display in the UI.

Do I have to do something with AndroidManifest.xml?

1 Answer

0 votes
by (46k points)

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;

No Setting object required!

Also, secure to define them in your build.gradle file rather of the AndroidManifest.xml.

defaultConfig {

versionCode 1

versionName "1.0"

}

Related questions

0 votes
1 answer
asked Apr 6, 2021 in Java by Jake (7k points)
0 votes
1 answer
asked Oct 31, 2019 in Java by Anvi (10.2k points)

Browse Categories

...