How to change the version of app in android studio - android

I have uploaded an app in Play Store before and now I created second version of that app and ready to upload in Play Store. I changed the version name and code in build.gradle(Module:app) from 1 to 2. It took that Version code but while uploading the app in google play console , But in Google Play Console It is showing that this version already exists. Change the version and upload again.

In build.app have youe changed both version code and version name
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.sb.android.acg.test"
minSdkVersion 17
targetSdkVersion 27
versionCode 1 // update this
versionName "1.0" // update this
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
To answer Eric's question
1:find the "Project" toolbar (if you are using windows press Alt+1)
2:Inside Project make sure you have opened Android option and not project or any other(it's located on the top of the window you just opened)
3:Open "Gradle scripts"
4:Click build.gradle (Module:app)

It's very easy to do. Follow the simple steps
Right-click on the app folder ---> Open Module Settings
Select Modules from the left panel, under the Default Config tab, update the Version Code and Version Name.
Version Code always is an integer. You have to update it every time when you release new version of the application.
You can set the Version Name according to your needs. As an example, if you fix minor bugs or update, your Version Name like 2.1, 2.2, etc If you fix major bugs or add more features your Version Name should like 3.0, 4.0, etc.

Related

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

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?
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.

Fully shadowed APK When try to publish apk in play store

I want to publish my app to Play store. but i faced some strange problem, i don't know what i should to do.
When i was upload App Bundle file app.abb and tried to upload apk-released.apk file, the play store console said me
"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 1."
The screenshot is here: https://drive.google.com/file/d/1N6xP8lGMfUoQh9EcC98BvO2KS_m49tas/view?usp=sharing
Then i was changed the version code to 2
the code is here
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
// buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.banglaralonews.app"
minSdkVersion 17
targetSdkVersion 26
versionCode 2
versionName "1.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
manifestPlaceholders = [onesignal_app_id : "",
// Project number pulled from dashboard, local value is ignored.
onesignal_google_project_number: "REMOTE"]
}
then it's uploaded fine but there occurred another strange problem the console said "Fully shadowed APK"
Screenshot is there:
https://drive.google.com/file/d/1-pBXk1NvxPB_Wqe6IH4b8-vHb-SNwvx3/view?usp=sharing
then i was delete the project again and again i was tried like this but the same problem. so please help me to publish my apk.
The problem is that you're trying to retain your previous APK (version code 1), which you don't need to. Just deactivate the older version of the APK then you will be able to rollout the new version... Also, always check for existing questions on the same topic.
It works for me to change the version code 2.4 -->2.5
I did not encounter such a problem, but I would try to make versionCode higher than usual, for example 10 or 20. And versionName 2.0.
I remember I forgot what version I already had in the Google Play store and randomly set 16 to accurately overcome the limit and I managed to do it successfully.

my app is not running in android KITKAT [duplicate]

I want to change the minimum SDK version in Android Studio from API 12 to API 14. I have tried changing it in the manifest file, i.e.,
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="18" />
and rebuilding the project, but I still get the Android Studio IDE throwing up some errors. I presume I have to set the min SDK in 'project properties' or something similar so the IDE recognizes the change, but I can't find where this is done in Android Studio.
When you want to update your minSdkVersion in an existing Android project...
Update build.gradle (Module: YourProject) under Gradle Script and
make sure that it is NOT build.gradle (Project: YourProject.app).
An example of build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion "28.0.2"
defaultConfig {
applicationId "com.stackoverflow.answer"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dependencies {
androidTestCompile 'junit:junit:4.12'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
Sync gradle button (refresh all gradle projects also works).
or
Rebuild project
After updating the build.gradle's minSdkVersion, you have to click on the button to sync gradle file ("Sync Project with Gradle files"). That will clear the marker.
Updating manifest.xml, for e.g. deleting any references to SDK levels in the manifest file, is NOT necessary anymore in Android Studio.
Update 2022
For Android Studio users:
Right click the App directory and
Choose the "Open Module Settings" (F4) option
Change the "Min SDK Version" in the Default Config tab
NOTE:
You might also want to change;
the "Target SDK Version" in the Default Config tab and
the "Compile SDK Version" in the Properties tab
Click Apply, then OK, and Gradle should automatically be synced
For users of older Android Studio versions:
Right click the App directory and
Choose the "Module Setting" (F4) option
Change the ADK Platform to what you need
Click OK and Gradle should automatically be synced
As now Android Studio is stable, there is an easy way to do it.
Right click on your project file
Select "Open Module Settings"
Go to the "Flavors" tab.
Select the Min SDK Version from the drop down list
PS: Though this question was already answered but Android Studio has changed a little bit by its stable release. So an easy straight forward way will help any new answer seeker landing here.
In android studio you can easily press:
Ctrl + Shift + Alt + S.
If you have a newer version of android studio, then press on app first.
Then, continue with step three as follows.
A window will open with a bunch of options
Go to Flavors and that's actually all you need
You can also change the versionCode of your app there.
In build.gradle change minSdkVersion 13 to minSdkVersion 8 Thats all you need to do. I solved my problem by only doing this.
defaultConfig {
applicationId "com.example.sabrim.sbrtest"
minSdkVersion 8
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
According to this answer, you just don't include minsdkversion in the manifest.xml, and the build system will use the values from the build.gradle file and put the information into the final apk.
Because the build system needs this information anyway, this makes sense. You should not need to define this values two times.
You just have to sync the project after changing the build.gradle file, but Android Studio 0.5.2 display a yellow status bar on top of the build.gradle editor window to help you
Also note there at least two build.gradle files: one master and one for the app/module. The one to change is in the app/module, it already includes a property minSdkVersion in a newly generated project.
For the latest Android Studio v2.3.3 (October 11th, 2017) :
1. Click View on menu bar
2. Click Open Module Settings
3. Open Flavors tab
4. Choose Min Sdk version you need
6. Click OK
If you're having troubles specifying the SDK target to Google APIs instead of the base Platform SDK just change the compileSdkVersion 19 to compileSdkVersion "Google Inc.:Google APIs:19"
As well as updating the manifest, update the module's build.gradle file too (it's listed in the project pane just below the manifest - if there's no minSdkVersion key in it, you're looking at the wrong one, as there's a couple). A rebuild and things should be fine...
In Android studio open build.gradle and edit the following section:
defaultConfig {
applicationId "com.demo.myanswer"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
here you can change minSdkVersion from 12 to 14
File>Project Structure>Modules
you can change it from there
When you want to change minimum SDK you should take care of minSdkVersion[About] in module build.garadle
android {
defaultConfig {
minSdkVersion 21
}
}
Changing the minSdkVersion in the manifest is not necessary. If you change it in the gradle build file, as seen below, you accomplish what you need to do.
defaultConfig {
applicationId "com.demo.myanswer"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
To change the minimum SDK version in Android Studio just...
1). Right click on "app" in the "Project" panel
2). Choose the new "Min SDK Version" on the "Default Config" tab
3). Click on "OK" and the project will now resync with the new Gradle settings.
For me what worked was: (right click)project->android tools->clear lint markers. Although for some reason the Manifest reverted to the old (lower) minimum API level, but after I changed it back to the new (higher) API level there was no red error underline and the project now uses the new minimum API level.
Edit: Sorry, I see you were using Android Studio, not Eclipse. But I guess there is a similar 'clear lint markers' in Studio somewhere and it might solve the problem.
Gradle Scripts ->
build.gradle (Module: app) ->
minSdkVersion (Your min sdk version)

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

According to this answer How to solve "Your APK's version code needs to be higher than 2." in Google Play's Developer Console? I have just changed the version code from 2 to 3 and it failed to upload the build.
This is my old manifest before I uploaded the apk
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="mypackage name"
android:installLocation="auto"
android:versionCode="28"
android:versionName="1.0028" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
.....
here is the new version code which I have to upload on android developer console. See my menifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="mypackage name"
android:installLocation="auto"
android:versionCode="2"
android:versionName="2.0001" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
......
I dont know whats the issue. Any help?
For people who use Android Studio the problem may be solved by editing versionCode and versionName in build.gradle instead of AndroidManifest.xml.
e.g.
defaultConfig {
applicationId "com.my.packageId"
minSdkVersion 15
targetSdkVersion 22
versionCode 2 <-- change this
versionName "2.0" <-- change this
}
android:versionCode="28"
Your previous versionCode was 28. You should increment it by 1 to 29.
android:versionCode="29"
Presumably, your previous app versions were 1 through 28. By releasing with versionCode 3, you are conflicting with a previous version of your app that was already released with this versionCode.
In my case it a simple issue. I have uploaded an app in the console before so I try re-uploading it after resolving some issues.
All I do is delete the previous APK from the App Bundle Explorer (formally called Artifact Library)
if you are using ionic framework, go to config.xml file and change the "version" attribute in the "widget" tag. increase the version number. then rebuild, sign and upload ur apk to play store. that fixed my problem.
This error appears when you try to upload an apk that has same version values as the one already on playstore.
Just change the following in your build.gradle file => versionCode and versionName
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"
}
(For Flutter App) You need to use a different version code for your APK or Android App Bundle because you already have one with version code 1.
Don't be panic...
You need to change in Flutter Version from pubspec.yaml file and Version Code from local.properties file.
First go to your pubspec.yaml file. The first three lines should be name, description and version of App.
Before Release -
For you the version might look something like this:
version: 1.0.0+1
So before creating an apk for release (for update your exiting app on Google Play Console i.e for new update) make sure you increment this number by 1. (You should increment it as there's no requirement on increment step) .
Solution
Just change that version to (As per your need )
version: 1.0.1+2
And Second if
flutter.versionCode in Project -> android -> local.properties is
flutter.versionCode=1 then change it or upgrade it to the flutter.versionCode=2 or any other greater number than previous code.
And finally release the app as per documentation.
Sometimes the PlayStore encounters a bug when you upload an APK during a Release creation, and you are stuck because you cannot upload the same APK again, for the current draft release. You get the error "Upload failed..."
The solution is to go to the Artifact library menu, under Release management and to delete the draft artifact. Once this is done, you will be able to upload the APK again, and to finish your release.
Hope it will help others...
Ben
If you're using Building Standalone Apps with Expo, the versionCode error might creep up owing to the fact that the standard app.json config only has a reference to the version property.
I was able to add a versionCode property under android as follows:
Sample App.json
{
"expo": {
"sdkVersion": "29.0.0",
"name": "App Name",
"version": "1.1.0",
"slug": "app-name",
"icon": "src/images/app-icon.png",
"privacy": "public",
"android": {
"package": "com.madhues.app",
"permissions": [],
"versionCode": 2 // Notice the versionCode added under android.
}
}
}
Detailed documentation: https://docs.expo.io/versions/v32.0.0/workflow/configuration/#versioncode
In Android Studio 1.1.0, change versionCode in build.gradle for Module: app and don't necessarily change versionName:
android {
...
defaultConfig {
...
versionCode 3
versionName "1.0"
}
...
}
Just as Martin Konecny's answer said, you need to change the versionCode to something higher.
Your previous version code was 28. it should be changed to 29.
According to the document on the android developer website. a version code is
An integer value that represents the version of the application code, relative to other versions.
So it should be related(by related I mean higher) to the previous versionCode as noted by the document:
you should make sure that each successive release of your application uses a greater value.
As mentioned again in the document
the android:versionCode value does not necessarily have a strong resemblance to the application release version that is visible to the user (see android:versionName, below)
So even though this is the release 2.0001 of your app, it does not necessarily mean that the versionCode is 2.
Hope this helps :)
If you're using Android Studio, you could go:
Build -> Edit Flavors
And change the Version Code and Name from there.
if you are using phonegap / cordova applications, just edit your config.xml and add the android-versionCode and version in the widget.
<widget id="com.xxx.yyy" version="1.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"
android-versionCode="100001"
version="1.0.1">
2021! For Flutter developers!
in your pubspec.yaml:
Detailed answer is here
Don't put feedback after!
Last Updated 18-12-2021:
Go to Google Play Console if you want to delete or revised same version and choose “App Bundle Explorer”:
Pick the version:
If you have build version that not been released yet, you can delete it. Delete options not showed when you don’t have pending release.
Or if you just simply ignore pending release, you can use new build. Go to pubspec.yaml and set this:
version: 1.4.17+67
That’s for example if you have version: 1.4.17+66 before.
If you get this error for your Flutter App's Android APK, in your app/build.gradle file under defaultConfig {}
comment out
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
and add
versionCode 2
versionName "2"
or "previous version code" + 1.
I received the same error while uploading a flutter app to playstore simply change the version code in pubspec.yaml worked for me. may be try changing the version code e.g from +1 to +2 and then rebuild the apk using
flutter build apk --split-per-abi
and upload all the apk's to the playstore for your users.
Next time when you want to push an update make sure to update the version code to +3 and so on.
Note: that the version code and version name are different you can see
that in android/local.properties file.
e.g version: 1.0.0+2
version is 1.0.0 and verison code is +2
just change the version code in yaml file.
version: 1.0.0+2 --> 1.0.0+3
This seems because you have already uploaded APK file of version 3 to Google Play Store. And again you are uploading apk with same version. So this issue has been occurred.
So for solution you need to change your version name and version code (increment with 1)and run application once and after export it upload to Google Play.
I kept getting same error again and again, Finally I uploaded the apk file manually using Google Play Console as shown in screen shot. Under App Release, You select the button "CREATE RELEASE" shown in the screen shot and upload your apk file from /android/app/bin/build/outputs/apk/release/app-release.apk
In my case I had something like this in my AndroidManifest,
javaCompileOptions {
annotationProcessorOptions {
arguments = [
'androidManifestFile': 'app\\build\\intermediates\\merged_manifests\\debug\\processDebugManifest\\merged\\AndroidManifest.xml'
]
}
}
here the 'androidManifestFile' location is wrong, changed it to
"androidManifestFile": "$projectDir/src/main/AndroidManifest.xml".toString()
everything worked
In my app/build.gradle file , version code was like this:-
In place of versionCode flutterVersionCode.toInteger() , i replaced it with as
versionCode 2
For flutter and bitbucket pipelines.
You could use the command flutter build apk --release --build-number=YOURVARNUMBER
--build-number=4 lets you assign the build number 4 when you compile apk file.
This can be used to increment the number in a pipeline build. For instance if you use some kind of continues integration pipeline. Like bitbucket pipelines, you can write
flutter build apk --release --build-number=$BITBUCKET_BUILD_NUMBER this way each build will automatically have an incremented number, rather then you having you write this number yourselfe.

Changing API level Android Studio

I want to change the minimum SDK version in Android Studio from API 12 to API 14. I have tried changing it in the manifest file, i.e.,
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="18" />
and rebuilding the project, but I still get the Android Studio IDE throwing up some errors. I presume I have to set the min SDK in 'project properties' or something similar so the IDE recognizes the change, but I can't find where this is done in Android Studio.
When you want to update your minSdkVersion in an existing Android project...
Update build.gradle (Module: YourProject) under Gradle Script and
make sure that it is NOT build.gradle (Project: YourProject.app).
An example of build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion "28.0.2"
defaultConfig {
applicationId "com.stackoverflow.answer"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dependencies {
androidTestCompile 'junit:junit:4.12'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
Sync gradle button (refresh all gradle projects also works).
or
Rebuild project
After updating the build.gradle's minSdkVersion, you have to click on the button to sync gradle file ("Sync Project with Gradle files"). That will clear the marker.
Updating manifest.xml, for e.g. deleting any references to SDK levels in the manifest file, is NOT necessary anymore in Android Studio.
Update 2022
For Android Studio users:
Right click the App directory and
Choose the "Open Module Settings" (F4) option
Change the "Min SDK Version" in the Default Config tab
NOTE:
You might also want to change;
the "Target SDK Version" in the Default Config tab and
the "Compile SDK Version" in the Properties tab
Click Apply, then OK, and Gradle should automatically be synced
For users of older Android Studio versions:
Right click the App directory and
Choose the "Module Setting" (F4) option
Change the ADK Platform to what you need
Click OK and Gradle should automatically be synced
As now Android Studio is stable, there is an easy way to do it.
Right click on your project file
Select "Open Module Settings"
Go to the "Flavors" tab.
Select the Min SDK Version from the drop down list
PS: Though this question was already answered but Android Studio has changed a little bit by its stable release. So an easy straight forward way will help any new answer seeker landing here.
In android studio you can easily press:
Ctrl + Shift + Alt + S.
If you have a newer version of android studio, then press on app first.
Then, continue with step three as follows.
A window will open with a bunch of options
Go to Flavors and that's actually all you need
You can also change the versionCode of your app there.
In build.gradle change minSdkVersion 13 to minSdkVersion 8 Thats all you need to do. I solved my problem by only doing this.
defaultConfig {
applicationId "com.example.sabrim.sbrtest"
minSdkVersion 8
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
According to this answer, you just don't include minsdkversion in the manifest.xml, and the build system will use the values from the build.gradle file and put the information into the final apk.
Because the build system needs this information anyway, this makes sense. You should not need to define this values two times.
You just have to sync the project after changing the build.gradle file, but Android Studio 0.5.2 display a yellow status bar on top of the build.gradle editor window to help you
Also note there at least two build.gradle files: one master and one for the app/module. The one to change is in the app/module, it already includes a property minSdkVersion in a newly generated project.
For the latest Android Studio v2.3.3 (October 11th, 2017) :
1. Click View on menu bar
2. Click Open Module Settings
3. Open Flavors tab
4. Choose Min Sdk version you need
6. Click OK
If you're having troubles specifying the SDK target to Google APIs instead of the base Platform SDK just change the compileSdkVersion 19 to compileSdkVersion "Google Inc.:Google APIs:19"
As well as updating the manifest, update the module's build.gradle file too (it's listed in the project pane just below the manifest - if there's no minSdkVersion key in it, you're looking at the wrong one, as there's a couple). A rebuild and things should be fine...
In Android studio open build.gradle and edit the following section:
defaultConfig {
applicationId "com.demo.myanswer"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
here you can change minSdkVersion from 12 to 14
File>Project Structure>Modules
you can change it from there
When you want to change minimum SDK you should take care of minSdkVersion[About] in module build.garadle
android {
defaultConfig {
minSdkVersion 21
}
}
Changing the minSdkVersion in the manifest is not necessary. If you change it in the gradle build file, as seen below, you accomplish what you need to do.
defaultConfig {
applicationId "com.demo.myanswer"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
To change the minimum SDK version in Android Studio just...
1). Right click on "app" in the "Project" panel
2). Choose the new "Min SDK Version" on the "Default Config" tab
3). Click on "OK" and the project will now resync with the new Gradle settings.
For me what worked was: (right click)project->android tools->clear lint markers. Although for some reason the Manifest reverted to the old (lower) minimum API level, but after I changed it back to the new (higher) API level there was no red error underline and the project now uses the new minimum API level.
Edit: Sorry, I see you were using Android Studio, not Eclipse. But I guess there is a similar 'clear lint markers' in Studio somewhere and it might solve the problem.
Gradle Scripts ->
build.gradle (Module: app) ->
minSdkVersion (Your min sdk version)

Categories

Resources