Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"You need to use a different version code for your APK or Android App Bundle" No matter what version code set

I am trying to upload a new update for the beta version of my last app on google play store.

I've tried several version codes, 1,2,3,29 !! But no matter what version code is set, it shows this error

Upload failed You need to use a different version code for your APK or Android App Bundle because you already have one with version code 29

please note that the last version of the app is actually 1.

Here is a part of my gradle app

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.company.myapp"
        minSdkVersion 18
        targetSdkVersion 28
        versionCode 29
        versionName "29.2.5"
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}
like image 464
Mostafa Ata Avatar asked Jun 19 '19 19:06

Mostafa Ata


People also ask

How do I change APK to app bundle?

To generate App Bundle manually, just go to Build →Generate Signed Bundle or APK, then pick Android App Bundle, and continue as usual. Just one note that, the output will not be the usual app/build/outputs/ folder. Instead it will be the folder destiny you indicate in the final dialog before generate the App Bundle.

What is the difference between APK and APK bundle?

App bundles are publishing format, whereas APK (Android application Package) is the packaging format which eventually will be installed on device. Google uses app bundle to generate and serve optimized APKs for each user's device configuration, so they download only the code and resources they need to run your app.

What is APK version code?

android:versionCodeAn internal version number. This number is used only to determine whether one version is more recent than another, with higher numbers indicating more recent versions. This is not the version number shown to users; that number is set by the versionName attribute.


3 Answers

If you're developing using Flutter:

version:A.B.C+X
eg: 1.0.0+2

Modifying X is a must because X is the version code. Then run:

flutter pub get
flutter clean
flutter build appbundle

It worked for me.

like image 88
DevSec Guy Avatar answered Oct 03 '22 22:10

DevSec Guy


For flutter users, u can also try directly replacing the version code in android projects build.gradle of app like this :

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '7'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.2.1'
}

with this:

def flutterVersionCode = '7'

def flutterVersionName = '1.2.1'

Be sure to update it next time.

like image 35
Bensal Avatar answered Oct 03 '22 20:10

Bensal


It was strange to find the solution, that the problem is not that the app is not being accepted on play store, but some double upload happened because of the bad internet connection, so that the app is keep uploading again, after it is being already uploaded.

I noticed that after finishing the upload it shows again 99% uploading, then the error occured.

When I checked after 2 days, I found that those versions 2,3,29 have been successfully uploaded !

So It is not an issue in the bundle or apk, but on google console in uploading process handling slow internet connections.

like image 27
Mostafa Ata Avatar answered Oct 03 '22 20:10

Mostafa Ata