Home > DeveloperSection > Forums > How to get the build/version number of your Android application?
Felix Pickles
Felix Pickles

Total Post:24

Posted on    August-10-2015 12:59 AM

 Android Android  Android Emulator 

 1 Reply(s)
 607  View(s)
Rate this:
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?

Mayank Tripathi
Mayank Tripathi

Total Post:397

Posted on    August-10-2015 5:54 AM

PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
version = pInfo.versionName;

String versionName = context.getPackageManager()
    .getPackageInfo(context.getPackageName(), 0).versionName;

If you're using the Gradle plugin/Android Studio, as of version 0.7.0, version code and version name are available statically in BuildConfig:
int versionCode = BuildConfig.VERSION_CODE;
String versionName = BuildConfig.VERSION_NAME;

Don't want to miss updates? Please click the below button!

Follow MindStick