Hello! When downloading a new version of the application to Google Play, an error of the following type occurs: An APK file with version 1 code already exists. Use another code. The question is where and how can this code be replaced?

    3 answers 3

    Update

    in build.gradle(Module: app)

     android { ... defaultConfig { ... versionCode 2 //для Google Play versionName "1.1" //для пользователей } } 

    in the manifest your project

      <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="......" android:versionCode="26" android:versionName="3.1.6"> 
    • t, e to just replace the code instead of xml version = "1.0" we put xml version = "2.0" and then create apk? - Vyacheslav
    • no-no, I indicated the part where the code version changes. - iFr0z

    In order for Google Play to accept the new version of the application, you need to upgrade the version of the android:versionCode code android:versionCode . If earlier android:versionCode="1" , then in the new version it should be 1 more - android:versionCode="2" .

    If you are writing applications in the Android Studio development environment. Using the Gradle build system, then the code version will need to be increased in the application-level build.gradle file, that is, in the /app folder. Inside this file you can easily find the versionCode line.

    versionName - Your own version of the application, it can be shown to users. It can be double, triple, with letters.

    Wikipedia details more on this - Software Version Numbering

    After that, you need to collect *.apk through Build-Generate signed APK...

    Successes!

    • and the string versionName "1.0" needs to be replaced with the string versionName "2.0"? - Vyacheslav
    • @ Vyacheslav, not necessarily the one. You can write 1.1. Or 1.0.1. versionName is for yourself and users. As you wish, and write. - web_alex
    • @ Vyacheslav, I updated my answer. Sorry, please, attach the wrong link for the first time (((Right now. The article describes the answer to your question about versionName . - web_alex

    If you work in Android Studio, then go to the project structure - the button on the toolbar or File / Project Structure ... or the keyboard shortcut Ctrl + Alt + Shift + S.

    Go to the settings of your application Modules / app , the Flavors tab. There you can change the version code (+ 1) and the version name (if necessary). To publish an update on Google Play, you only need to change the version code.