[android] How to change Android version and code version number?

How to change Android version and code version number Android Studio? I want to change apk file (app) on Google Play and I need to change Android version and code version number. I tried with this in AndroidManifest.xml file in Android Studio:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.bestsoftcorporation.circle.app"
android:versionCode="101"
android:versionName="2.0">

But it does not work. When I tried to publish it on Google Play it display that I must to change Android version name and code.

This question is related to android google-play android-manifest

The answer is


You can define your versionName and versionCode in your module's build.gradle file like this :

android {
    compileSdkVersion 19
    buildToolsVersion "19.0.1"

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }
    .... //Other Configuration
}

Android version and code version number change on Android Studio >= 3.6:

Two ways to achieve this:

  1. Direct on the Android project by Open Flutter project and modify the file

    local.properties

change the following values. Example:

flutter.buildMode=release
flutter.versionName=3.0.0
flutter.sdk=C\:\\src\\flutter
sdk.dir=C\:\\Users\\vgonza\\AppData\\Local\\Android\\sdk
flutter.versionCode=30
  1. Open pubspec.yaml

Change the

version: 2.0.0+8

Meaning: The version name is 2.0.0 The version code is 8

See example by Suragch in:

How to set build and version number of Flutter app


The easiest way to set the version in Android Studio:

1. Press SHIFT+CTRL+ALT+S (or File -> Project Structure -> app)

Android Studio < 3.4:

  1. Choose tab 'Flavors'
  2. The last two fields are 'Version Code' and 'Version Name'

Android Studio >= 3.4:

  1. Choose 'Modules' in the left panel.
  2. Choose 'app' in middle panel.
  3. Choose 'Default Config' tab in the right panel.
  4. Scroll down to see and edit 'Version Code' and 'Version Name' fields.

After updating the manifest file, instead of building your project, go to command line and reach the path ...bld\Debug\platforms\android. Run the command "ant release". Your new release.apk file will have a new version code.


I didn't get the other answers to work in Android Studio 1.4. But this worked: click on your app name to the left below the main ribbon. It will show a list of files. Open AndroidManifest.xml and change the version code and version number there.


Open your build.gradle file and make sure you have versionCode and versionName inside defaultConfig element. If not, add them. Refer to this link for more details.


Go in the build.gradle and set the version code and name inside the defaultConfig element

defaultConfig { minSdkVersion 9 targetSdkVersion 19 versionCode 1 versionName "1.0" }


You can manage your application versioning wisely by using the Advanced Build Version Plugin for Gradle.

You just need to include the plugin in yout build.gradle:

buildscript {
  repositories {
      jcenter()
  }

  dependencies {
      classpath 'org.moallemi.gradle.advanced-build-version:gradle-plugin:1.5.0'
  }
}

apply plugin: 'org.moallemi.advanced-build-version'

And then you can use the versioning functions (and, obviously, customize them):

advancedVersioning {
    nameOptions { }
    codeOptions { }
    outputOptions { }
}

def appVersionName = advancedVersioning.versionName
def appVersionCode = advancedVersioning.versionCode

For more information, take a look at the official documentation.


You can easily auto increase versionName and versionCode programmatically.

For Android add this to your gradle script and also create a file version.properties with VERSION_CODE=555

android {
        compileSdkVersion 30
        buildToolsVersion "30.0.3"
    
        def versionPropsFile = file('version.properties')
        if (versionPropsFile.canRead()) {
            def Properties versionProps = new Properties()
    
            versionProps.load(new FileInputStream(versionPropsFile))
    
            def code = versionProps['VERSION_CODE'].toInteger() + 1
    
            versionProps['VERSION_CODE'] = code.toString()
            versionProps.store(versionPropsFile.newWriter(), null)
    
    
            defaultConfig {
                applicationId "app.umanusorn.playground"
                minSdkVersion 29
                targetSdkVersion 30
                versionCode code
                versionName code.toString()

Press Ctrl+Alt+Shift+S in android studio or go to File > Project Structure... Select app on left side and select falvors tab on right side on default config change version code , name and etc... enter image description here


Examples related to android

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How to implement a simple scenario the OO way My eclipse won't open, i download the bundle pack it keeps saying error log getting " (1) no such column: _id10 " error java doesn't run if structure inside of onclick listener Cannot retrieve string(s) from preferences (settings) strange error in my Animation Drawable how to put image in a bundle and pass it to another activity FragmentActivity to Fragment A failure occurred while executing com.android.build.gradle.internal.tasks

Examples related to google-play

How to enable Google Play App Signing google console error `OR-IEH-01` Is Google Play Store supported in avd emulators? updating Google play services in Emulator How to change package name in android studio? How to change Android version and code version number? Check if application is installed - Android Where do alpha testers download Google Play Android apps? Is it possible to change the package name of an Android app on Google Play? "Insufficient Storage Available" even there is lot of free space in device memory

Examples related to android-manifest

Warnings Your Apk Is Using Permissions That Require A Privacy Policy: (android.permission.READ_PHONE_STATE) Android - Adding at least one Activity with an ACTION-VIEW intent-filter after Updating SDK version 23 Getting net::ERR_UNKNOWN_URL_SCHEME while calling telephone number from HTML page in Android How to change Android version and code version number? Error type 3 Error: Activity class {} does not exist Android open pdf file Adding Permissions in AndroidManifest.xml in Android Studio? Sending and Receiving SMS and MMS in Android (pre Kit Kat Android 4.4) Get Android .apk file VersionName or VersionCode WITHOUT installing apk versionCode vs versionName in Android Manifest