I get this error when uploading my app: Upload failed You need to use a different version code for your APK than version code 1

512

In Flutter, at least in my experience, you don't need to modify version codes anywhere but in pubspec.yaml. Say your version tag there is version: 1.0.0+1, your android version code will be 1 and your user visible version name is 1.0.0. You can change this to version: 1.1.0+2, for example, and that should fix your problem.

Edit: And, obviously, rebuild.

Share:
512
Tobias H.
Author by

Tobias H.

Updated on December 04, 2022

Comments

  • Tobias H.
    Tobias H. over 1 year

    I have an app on google play store. Currently there's only one upload.

    And I want to upload a new version, but when ever I do that this error shows:

    Upload failed You need to use a different version code for your APK because you already have one with version code 1

    No matter weather it is versioncode 1, 2 or 3. The first release way versioncode 1, and this is versioncode 2.

    I don't know what the problem is, maybe I have to sync the build.gradle, I've heard some ppl talk about that, but I am not 100% sure how to?

    Also If I make a new 'App' and upload it there this error doesn't show op, that's probably because on that 'app' there's no other app-release with that name, or any with higher.

    Also, there's like 300 different build.gradle files, the one I am talking about is the one under the directory

    ApplicatioName\myApplication\build.gradle
    

    Here is the build.gradle:

    defaultConfig {
            applicationId "com.example.myapplication"
            minSdkVersion 16
            targetSdkVersion 30
            versionCode 2
            versionName "2.0"
    
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
    

    What do I do?

    • lucidbrot
      lucidbrot over 3 years
      Very naïve of me to ask, but sometimes the simplest things are the culprits: Did you recreate the APK after you changed the version code?
    • Michael
      Michael over 3 years
      "ApplicatioName\myApplication\build.gradle" Typically the build.gradle where you modify this setting would be in a subdirectory named app.
    • Ulaş Kasım
      Ulaş Kasım over 3 years
      what was versionName on versionCode 1 ?
    • Tobias H.
      Tobias H. over 3 years
      @lucidbrot Yea I did do that a lot :)
    • Tobias H.
      Tobias H. over 3 years
      @Michael oh, yea I just opened that file, I do not find 'versionName'/'versionCode'. Bu there's something called FlutterVersionName = '2.0' And FlutterVersionCode = '4'. Do I change those, or and if so, why is the versioncode 4, and versionname 2 by default?
    • Tobias H.
      Tobias H. over 3 years
      @UlaşKasım I'm not sure you've understood, the error says that I already have an apk/aab file with versioncode 1, but I've changed it, at least in the build.gradle at "ApplicatioName\myApplication\build.gradle" :)
  • Tobias H.
    Tobias H. over 3 years
    Thx a whole lot, it worked :) It was that simple, yet I had never heard of it before, somehow none of my thousands of google searches had answered this, and it was just what I needed :) Thx