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
?
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
?
Always do it with
try catch
block:Slightly shorter version if you just want the version name.
Use BuildConfig class
build.gradle(app)
There are two parts you need: android:versionCode android:versionName
versionCode is a number, and every version of the app you submit to the Market needs to have a higher number then the last.
VersionName is a string, and can be anything you want it to be. This is where you define your app as "1.0" or "2.5" or "2 Alpha EXTREME!" or whatever.
Example:
To access it in code, do something like: