I'm trying to deploy our Nativescript app to the Google Play Store using a YML pipeline in Azure DevOps. There is a deployment task that automatically increases the versionCode and versionNumber, which always used to work fine.
However now that we upload, I get this error:
##[error]Error: Failed to upload the bundle /Users/runner/work/1/_Android/app-release.aab. Failed with message:
Error: APK specifies a version code that has already been used..
I see that the latest version in Google Play store is 1.0.3601
In the release pipeline I see that the versionCode generated is 1.0.3603 and versionName is 1.0.3604
How can this be solved? What am I doing wrong?
As suggested by User Kingston Fortune - Stack Overflow, make sure to change versionCode and versionName in build.gradle file:
defaultConfig {
applicationId "com.my.packageId"
minSdkVersion 16
targetSdkVersion 27
versionCode 2 <-- increment this by 1
versionName "2.0" <-- this is the version that shows up in playstore,
remember that the versioning scheme goes as follows.
first digit = major breaking changes version
second digit = minor changes version
third digit = minor patches and bug fixes.
e.g versionName "2.0.1"
}
References: Upload failed You need to use a different version code for your APK because you already have one with version code 2 , Problem with build version when publishing APK to Play Store , https://github.com/bitrise-steplib/steps-google-play-deploy/issues/31 and https://developer.android.com/studio/publish/versioning#appversioning
I am uploading new app bundle to play console and it is saying after uploading Version code 1 has already been used. Try another version code.
I have changed version number in pubspec.yaml from version number: 1.0.0+1 to 2.0.0+1 even though it is saying the same error
You have two ways to solve this, if you released your bundle already, then you have to update your version code like in Len_X's answer,
If you're still developing and pushed app bundle for say, testing, and then you delete it, this bundle is saved as a draft with that version code. Therefore, it says that you can't use the same version because it already sees another one with the same version name.
Here's how you fix it:
Go to the release section
go to app bundle explorer, in the top right you should see a dropdown button for you app version, click on it.
A bottomsheet will show containing all the previous app bundles you uploaded it. Delete the one with clashing bundle version and you're good to go.
Hope that solves your problem.
You can do it manually by going to "app_name/android/app/build.gradle" file. In defaultConfig section change version code to a higher number
defaultConfig {
applicationId "com.my.app"
minSdkVersion 23
targetSdkVersion 30
versionCode 1 // Change to a higher number
versionName "1.0.1" // Change to a higher number
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
javaCompileOptions {
annotationProcessorOptions {
arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
}
}
}
First go to the app/build.gradle
change versionCode and versionName like this (+1)
I think this will be helpful for someone ✌😊
For Flutter only:
Goto Pubspec.yaml file and find version key and Change the value after the + sign.
For Example:
In your pubspec.yaml file, if your version is like this version: 1.0.0+1 then change it to version: 1.0.0+2
You have to increment the +1, it should be +2 to indicate build number
if you remove apk then upload same version apk so you get Error Version code 1 has already been used. Try another version code in this situation you should remove version from App bundle explorer then upload same version apk.
If you're running into app bundle approval issues inside of the Google Play store with an Expo/React Native project, here are some tips:
Google Play versioning is actually checking your AndroidManifest.xml file for versioning (/android/app/src/). This should get updated from Expo's app.json file (/app.json) during build, per their instructions.
app.json example section, where I've bumped my app up to a v2.0 - note the versionCode inside of the Android settings object AND the version at the settings object root both need to be adjusted:
{
"name": "app-name",
"displayName": "App Name",
"expo": {
"android": {
"package": "app.here",
"permissions": [],
"versionCode": 2
}
},
"version": "2.0.0"
}
If your Android version isn't updating (possibly if you have a detached Expo app), you have to go directly into the AndroidManifest.xml file and make the modification there (/android/app/src/):
Example of AndroidManifest.xml (note your modifications happen on the <manifest> tag, using the android:versionCode and android:versionName:
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.aganashapp"
android:versionCode="2"
android:versionName="2.0"
>
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:name=".MainApplication"
android:label="#string/app_name"
android:icon="#mipmap/ic_launcher"
android:allowBackup="false"
android:theme="#style/AppTheme"
>
<meta-data android:name="expo.modules.updates.EXPO_UPDATE_URL" android:value="https://exp.host/#username/app-name" />
<meta-data android:name="expo.modules.updates.EXPO_SDK_VERSION" android:value="42.0.0" />
<meta-data android:name="expo.modules.updates.EXPO_RELEASE_CHANNEL" android:value="default" />
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize"
android:theme="#style/Theme.App.SplashScreen"
>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity"/>
</application>
</manifest>
If you're still having issues, remember that Android versionCode and versionName are two different things. Android does not seem to recognize semver standards. versionCode increments as whole numbers (ie, if you went from semver v1.0.0 to v1.1.0 that is versionCode 1 to 2.
with my flutter project building a release for android i faced the same issue. all was doing is change version code in Pubspec.yaml but did not seem to change my android version...
so i went to Android folder and added version code manually in local.properties file :
/project/android/local.properties
flutter.versionName=1.1.0
flutter.versionCode= from 1 to 4
I always used to increment version code in my android/app/build.gradle file, and it always used to work. Then, after a recent update in Android Studio, it suddenly didn't anymore, and I got this error!
I never cared to dig into the build.gradle code, but now, I did. Here, at the "TODO", is where I used to change the version code number:
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new FileNotFoundException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '19' // TODO: ---Count up with each release
}
But that only works if the version code from the local.properties file comes back as "null"!... I just realized. So probably, all this time, my compiler never managed to get values from local properties, but now all of a sudden, it does!
So I found the android/local.properties file and tried changing the version code there:
sdk.dir=C:\\Users\\karol\\AppData\\Local\\Android\\sdk
flutter.sdk=C:\\src\\flutter
flutter.buildMode=release
flutter.versionName=1.0.0
flutter.versionCode=1 //Change this to 19 (my current version code number)
But that didn't work, because the moment I ran flutter build appbundle, this file changed itself back to the original values...
I then tried adding version code values to my AndroidManifest.xml file, according to serraosays' answer, but that didn't help me either.
Functioning work-around
In the end, I did this in the android/app/build.gradle file:
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
//if (flutterVersionCode == null) {
flutterVersionCode = '19' // TODO: ---Count up with each release
//}
That is, I commented out the condition. Now, my setting would over-write any value retrieved from the local.properties file.
If anyone can tell me the proper way to increment the version code number, I'm all ears! 🙂 But in the meantime, this worked for me, and hopefully for someone else as well.
If you get the above error in the google play console, please change the version: in pubspec.yaml.
Reference. How to set build and version number of Flutter app
and me works
The first step change the version code
The second step go to the other settings and change the bundle version code as well
There are two reasons for this error:
First, is common given in other answers: you must increase the version number to send an update to Play Console. Eg. previous app version: 1.0.5+5 and next update must contain 1.1.2+6. The +6 must be next to the previous update present on your play console.
Second reason for this error is you have skipped some numbers in between. Eg. Previous released version: 1.0.5+5 but the new version you are trying to release is 1.0.6+8. The +8 is not allowed directly, you must put +6 then +7 and then next numbers.
In unreal engine you can change this in project settings. Steps are as follows.
(Me I'm using UE4.27.2)
Step 1:
Open Project Settings
Step 2: Click all settings and in the top search bar type in "version" Without Quotes.
Step 3:
Scroll down to >Platforms>Android>apk packaging
Step 4:
Change the store Version for each +1 what you already have
APK PAckaging
(You do not need to change version display name but you can if you want to this can be edited later on in google console)
change version code here please check the imageenter image description here
Versioning works the other way around. Do not update the pubspec.yaml manually.
See the default comment in the pubspec.yaml:
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
So you should run
flutter build appbundle --build-name 2.0.0 --build-number 2
This updates the pubspec.yaml for you.
For hybrid apps/JavaScript based frameworks like Ionic or Flutter updating package.json is not enough you sometimes, can directly edit build.gradle file in the build folder.
versionCode 2
versionName "2.0"
This is not a good practice
I cant update my app in Play Store because I get a message: The following unknown languages are configured for your App Bundle: zz
Update
This problem is a known bug and it has been rectified already. Try to update the SDK to the latest version will also solve this issue.
You can go to the application's build.gradle file, which is in android->defaultConfig.
Then choose the languages using resConfigs
android {
defaultConfig {
...
resConfigs "en", "fr" //pick the languages you'd like to use
}
}
Then rebuild the .aab file and try uploading.
I have created an Android app in Phonegap Build few months ago and its working fine and available on Play Store .I have Published Couple of updates of my app and thay are all Published Successfully but today i want to publish new update of my app but its showing the error "Your APK Version code should be higher than 378 "
I have changed Version in config file and also changed the android:version code and version name in AndroidManifest file but nothing working for me .
Any help would be Appreciated .Thanks
I think I have the same problem as you.
In production, i have The Following release:
200118 (2.0.11)
Note that the 6-digit versionCode
I have updated Cordova Client (Cordova Android 5.2.1 and cordova#6.3.0)
I want to publish new release (my config.xml for the new version):
Widget id = "com.xxxxx.yyyyyyyyyyy" version = "2.1.1"
When I compile the release with Cordova, I get a manifest:
Manifest android: hardwareAccelerated = "true" android: versionCode =
"20101" android: versionName = "2.1.1"
Note that the 5-digit versionCode
When I want to publish on Google Play, so I get the same message as you: "Your APK version code shoulds be Higher Than 200118"
Cordova bug?
As a workaround, edit your config.xml, add "android-versionCode" and specify your versionCode manually:
widget id="com.xxxxx.yyyyyyyyyyy" android-versionCode="201018"
version="2.1.1"
And build
Your version in config.xml should be more than the previous one.Check my this answer link
apk upload failed to the google play market.
I am trying to upload the upgraded version of my app to the google play but I am keep getting the message -
Upload failed
You need to use a different version code for your APK because you already have one with version code 1.
Your APK needs to have the package name com.corntail.project.
There is still something that is looking for com.corntail.project and it is not being found.
UPDATE:
In my AndroidManifest.xml, the relevant code is -
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.corntail.main"
android:versionCode="1"
android:versionName="1.0" >
If you're using Android Studio or building with gradle, edit your gradle script (build.gradle) to change your package name and version. These values overwrite your AndroidManifest.xml file.
For example:
defaultConfig {
applicationId "com.xyz.abc"
minSdkVersion 16
targetSdkVersion 19
versionCode 2
versionName "1.1"
}
You need to change your android:versionCode="1" to 2 on the AndroidManifest...
Things you have to keep in mind when updating your application on Google Play :
Change Version code +1 depending on the old value - if it's 1 , you have to change it to a bigger number.
Change your App Version Name to something bigger / different if it's string - if your old version is 1.0 - it should be 1.1 / 1.0.1 or whatever you like (it's always a better option t have some version name strategy, if it will contains the date update addded or the revision it depends on you).
And if you want to be able to update your app, don't change project package name! That's how android system knows that this application is different than that one. If you change your package name, it's now acting like a new app and you won't be able to update it from Google Play Store! To change your package name to com.corntail.project first you need to change it in manifest and after that in your project's main package and you need to keep track of your activities, if you declared them with package name too. For example :
if your MainActiivty was declared in manifest like :
com.corntail.main.MainActivity
you need to change it now to be like :
com.corntail.project.MainActivity.
You need to use a different version code for your APK because you
already have one with version code 1.
You must change your version code in your androidmanifest.xml
Every time you update your app change this variable in you XML file:
android:versionCode="1"
You are getting 2 errors.
The Version Code: you always need to set a higher number in the versionCode and always use an integer number. (don't use 1.1)
android:versionCode="1"
The package name: it has to match the same string that you used in the latest version that you upload. So instead of package="com.corntail.main" you should use:
package="com.corntail.project"
After modify the AndroidManifest.xml save it and then search in the folder src the package called "com.corntail.main", right click, Refactor > Rename, and the new name should match what you put in package (in this example you should call it: 'com.corntail.project') and you are done!
Good luck!
You have change version code in increasing order i.e. 1,2,3...so on as every time you uploaded. In every upload version code should have greater number than previous upload version code. You can change version code in APP Module Build.gradle file.
Image
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.xyz"
minSdkVersion 14
targetSdkVersion 24
versionCode 5
versionName "1.1.4"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
If you build with gradlew, you should check the build.gradle file,
the applicationId will overwrite the package value in the AndroidManifest.xml
android {
defaultConfig {
applicationId "xxx.xxx.xxx"
}
}