I'm almost done with my first android app, and I made an "envelope" page and manually entered the version number. Can I set the version somewhere? and how can you get it within the program?
I'm almost done with my first android app, and I made an "envelope" page and manually entered the version number. Can I set the version somewhere? and how can you get it within the program?
To retrieve the app version use:
PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
String version = pInfo.versionName;
int verCode = pInfo.versionCode;
The easiest and fastest way to change the version in Android Studio is:
Press SHIFT + CTRL + ALT + S
Choose the 'Flavors' tab
The last two fields are 'Version Code' and 'Version Name'
But you can also change by the file build.gradle
:
defaultConfig {
minSdkVersion 9
targetSdkVersion 19
versionCode 1
versionName "1.0"
}