Version code 1 has already been used. Try another version code - android

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

Related

Google play console upload new version for internal testing [duplicate]

I have published an application on the play store with flutter, now I want to upload a new version of the application. I am trying to change the version code with:
flutter build apk --build-name=1.0.2 --build-number=3
or changing the local.properties like this
flutter.versionName=2.0.0
flutter.versionCode=2
flutter.buildMode=release
but every time I get an error on the play store
You must use a different version code for your APK or your Android App Bundle because code 1 is already assigned to another APK or Android App Bundle.
Update version:A.B.C+X in pubspec.yaml.
For Android:
A.B.C represents the versionName such as 1.0.0.
X (the number after the +) represents the versionCode such as 1, 2, 3, etc.
Do not forget to execute flutter build apk or flutter run after this step, because: When you run flutter build apk or flutter run after updating this version in the pubspec file, the versionName and versionCode in local.properties are updated which are later picked up in the build.gradle (app) when you build your flutter project using flutter build apk or flutter run which is ultimately responsible for setting the versionName and versionCode for the apk.
For iOS:
A.B.C represents the CFBundleShortVersionString such as 1.0.0.
X (the number after the +) represents the CFBundleVersion such as 1, 2, 3, etc.
Do not forget to execute flutter build ipa or flutter run after this step
Figured this one out.
Documentation is not straight forward
in your pubspec.yaml change the version like this
version: 1.0.2+2
where the stuff is VER_NAME+VER_CODE
Solution:
Inside pubspec.yaml add this (probably after description, same indentation as of description, name etc...):
version: 2.0.0+2
Then do packages get inside flutter local directory (Do not forget to do this)
Explanation:
Everything before plus is version name and after is version code. So here the version code is 2 and name is 2.0.0. Whenever you give an update to the flutter app make sure to change the version code compulsorily!
Addtional Info:
Whenever android app is built, build.gradle inside android/app/ looks for version code and name. This usually lies in local.properties which is changed every time you change flutter pubspec.yaml
In case you already changed the versionCode, it may be because Play Console already accepted your build.
Instead of clicking on upload, click in Choose from library and choose the build that was already sent.
For Android
"X.Y.Z+n" here "x.y.z" represents the VERSION NAME and "n" represents the VERSION NUMBER.
The following changes to be made-
In pubspec.yaml change your version number.
Update your local.properties by running flutter pub get command.
Now build your apk or app bundle by running flutter build apk or flutter build appbundle command.
Updating the app’s version number
The default version number of the app is 1.0.0. To update it, navigate to the pubspec.yaml file and update the following line:
version: 1.0.0+1
The version number is three numbers separated by dots, such as 1.0.0 in the example above, followed by an optional build number such as 1 in the example above, separated by a +.
Both the version and the build number may be overridden in Flutter’s build by specifying --build-name and --build-number, respectively.
In Android, build-name is used as versionName while build-number used as versionCode. For more information, see Version your app in the Android documentation.
I don't think anyone has actually answered the question. A lot of suggestions are updating the version in pubspec. But depending on your deployment you might not use those values.
flutter build --build-number=X --build-name=Y
X gets used as your version code
Y gets used as your version name
To test just run build and check local.properties
still someone looking for a Good answer
in pubsec.yaml file
change version: 1.0.0+1 to version: 1.0.0+2
then open your code in android by selecting
File -> Open -> your Flutter Code workspace -> Android icon of project
Now go to build.gradel
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0.0'
}
to
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '2'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0.2'
}
Now last one local.property file
sdk.dir=C:/Users/Admin/AppData/Local/Android/Sdk
flutter.sdk=D:\\flutter_windows\\flutter
flutter.buildMode=debug
flutter.versionName=1.0.0
flutter.versionCode=1
to
sdk.dir=C:/Users/Admin/AppData/Local/Android/Sdk
flutter.sdk=D:\\flutter_windows\\flutter
flutter.buildMode=debug
flutter.versionName=1.0.2
flutter.versionCode=2
Follow these steps for above flutter 2.10.2 version
Step 1: Change following changes in pubspec.yaml
//change version 1.0.0+1 to 1.0.0+2
version: 1.0.0+2
environment:
sdk: ">=2.16.1 <3.0.0"
Step 2: Change following change in android\local.properties
flutter.sdk=C:\\flutter
flutter.buildMode=release
// Change here flutter.versionName=1.0.0 to flutter.versionName 1.0.1
flutter.versionName=1.0.1
//Change here flutter.versionCode=1 to flutter.versionCode=2
flutter.versionCode=2
flutter.minSdkVersion=21
flutter.targetSdkVersion=31
flutter.compileSdkVersion=31
Docs says the build args should override pubspec.yml:
Both the version and the build number may be overridden in Flutter’s
build by specifying --build-name and --build-number, respectively.
https://flutter.dev/docs/deployment/android#updating-the-apps-version-number
Check
android{
//....
defaultConfig {
//....
version code:2
}
}
on android>app>Build.gradle from your project's root folder
You can still do completely your own thing by overwriting in android/app/build.gradle:
def flutterVersionCode
def flutterVersionName
to your own values.
Something that might be helpful to others that land here, the Play Store only looks at the versionCode in isolation. So, if you've updated your versionNumber from, for example, 1.0.0+1 to 1.1.0+1 Play Store will throw an error that the versionCode has not changed. So, regardless of what your versionNumber is, you must also change your versionCode - as in, changing from 1.0.0+1 to 1.1.0+2
First one change flutter version in pubspec.yaml
example `version 1.0.3+4
In case of android go to local.properties than change version name and code same like flutter version code and name.
In case of Ios go to generated.xcconfig than chnage FLUTTER_BUILD_NAME=1.0.3
FLUTTER_BUILD_NUMBER=4`
I had the same problem, I solve it by restarting Android Studio.
in pubspec.yml version: 1.0.0+1
change to version: 1.0.0+2
flutter build ios --release-name --release-number will update version in ios
flutter pub get && flutter run will update version for android (android/local.properties)
this works for me!
I recognised that first app as Default Version Name 1.0.0 Version Number 1
so this means 1.0.0+1
I updated my app after I wrote as 1.0.0+2 in pubspec.yaml.
In my case, i solved the same exact problem by changing two files:
1- in pubspec.yaml:
from:
version: 1.0.0+1
to:
version: 1.0.0+2
2- in android/locale.properties
from:
flutter.versionName=1.0.0
flutter.versionCode=1
to:
flutter.versionName=1.0.0
flutter.versionCode=2
3-Last action:
flutter clean
flutter packages get
Any of the solution did not work for me with App Bundle, I changed to APK and no issues with the version.
Not clear why though.
All of these answers mirror the official documentation, and it is how I am setting my versionName and versionCode. But when I upload my build I get the same error as reported by the post author.
My previous version code on the play store shows as 4 (0.0.2) ... I am used to how iOS works so this looked odd to me. The number in the brackets should be the build/code number and the main number is the actual version number. Incrementing the build number when necessary without having to bump the version (because there are no significant changes).
So when I attempted to upload 0.0.3+1 with a new build number to increment for this new version, it complained that the 1 had already been used.
So how does this work on the Play store? I'm confused too.
before uploading the app bundle, first write the Release name.
I faced the same issue and That's worked for me.
For example if you to make android version 3 ,
For Android go to
pubspec.yaml and edit here
version: 3.0.0
and go to build.gradle and edit here
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '3'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '3.0'
Updating it in project/android/app/build.gradle worked for me.
defaultConfig {
versionCode 2 // this needs to be updated
versionName "1.0.5"
}
Hope this helps!
you can update the local.properties file,
I have been doing it like this in the 'app/build.gradle' file
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}else {
flutterVersionCode = '4'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}else {
flutterVersionName = '1.3'
}

Failure [INSTALL_FAILED_USER_RESTRICTED: Invalid apk] in android

I am using Android Studio 3.0.1.
When i am trying to run app
INSTALL_FAILED_USER_RESTRICTED: Invalid apk
error occurs.
I also disable Instant Run.
again i am run app but same error occurs.
04/04 10:59:08: Launching app
$ adb push G:\Android\Fundraiser\BuyForFund\app\build\outputs\apk\debug\app-debug.apk /data/local/tmp/com.android.buyforfund
$ adb shell pm install -t -r "/data/local/tmp/com.android.buyforfund"
Failure [INSTALL_FAILED_USER_RESTRICTED: Invalid apk]
$ adb shell pm uninstall com.android.buyforfund
DELETE_FAILED_INTERNAL_ERROR
Error while Installing APK
None of the other answers worked for me using Xiaomis MIUI 10 on a Mi 9 phone.
Besides the usual (like enabling USB debugging and Install via USB in the developer options) answers from other questions suggested turning off MIUI optimization. While this did the trick, I wasn't happy with it. So I did some digging and came to the following conclusions:
The described error only occurred the second time you deploy your app and after that keeps occurring every other time when deploying the same app to that phone.
To solve this I could either hit Run / press Shift + F10 again or unplug and plug in that phone again. None of this seems viable. So I did some more digging and it turns out when you are increasing the versionCode in your build.gradle file every time you build your app, MIUI 10 will not complain and let you install your app just like you would expect. Even Android Studios Instant Run works. Though doing this manually is just as annoying.
So I took some ideas to auto-increment the versionCode from this question and modified build.gradle (the one for your module, NOT the one for your project). You can do the same following these easy steps:
Replace
defaultConfig {
applicationId "your.app.id" // leave it at the value you have in your file
minSdkVersion 23 // this as well
targetSdkVersion 28 // and this
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
with
def versionPropsFile = file('version.properties')
def value = 0
Properties versionProps = new Properties()
if (!versionPropsFile.exists()) {
versionProps['VERSION_MAJOR'] = "1"
versionProps['VERSION_MINOR'] = "0"
versionProps['VERSION_PATCH'] = "0"
versionProps['VERSION_BUILD'] = "0"
versionProps.store(versionPropsFile.newWriter(), null)
}
def runTasks = gradle.startParameter.taskNames
if ('assembleRelease' in runTasks) {
value = 1
}
if (versionPropsFile.canRead()) {
versionProps.load(new FileInputStream(versionPropsFile))
versionProps['VERSION_PATCH'] = (versionProps['VERSION_PATCH'].toInteger() + value).toString()
versionProps['VERSION_BUILD'] = (versionProps['VERSION_BUILD'].toInteger() + 1).toString()
versionProps.store(versionPropsFile.newWriter(), null)
// change major and minor version here
def mVersionName = "${versionProps['VERSION_MAJOR']}.${versionProps['VERSION_MINOR']}.${versionProps['VERSION_PATCH']}"
defaultConfig {
applicationId "your.app.id" // leave it at the value you have in your file
minSdkVersion 23 // this as well
targetSdkVersion 28 // and this
versionCode versionProps['VERSION_BUILD'].toInteger()
versionName "${mVersionName} Build: ${versionProps['VERSION_BUILD']}"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
}
else {
throw new GradleException("Could not read version.properties!")
}
Now each time you build your app by hitting Run or Instant Run your versionCode / VERSION_BUILD increases.
If you build a release your VERSION_PATCH increases as well changing your versionName from x.y.z to x.y.z+1 (i.e. 1.2.3 turns to 1.2.4). To change VERSION_MAJOR (the x) and VERSION_MINOR (the y) edit the version.properties file which you can find in your module folder. If you didn't change your modules name it's called app so this file is located at app/version.properties.
Make sure you have enabled the following options:
Settings > Additional Settings > Developer options
USB Debugging
Install via USB
USB Debugging (Security settings)
I have the same problem, I sent a feedback to Google on my phone, would say it's a bug. In my case the best solution is to cancel that dialog and then re-run, it works always on second attempt after cancelling.
Depending on what phone you are using, I would assume the problem is on the phone (Google) side. Not sure yet if a general Google problem or specific hardware phones, I use "Xiaomi Redmi 5".
Disabling instant run actually worked in my case, but that's not the purpose of it, that's just a dirty workaround.
Edit:
Make sure that you don't have something like
android:debuggable="false"
in your manifest.
I ran into this same error while the underlying issue was different.
Mine was that I was trying to install my app on Android 12 device while the AndroidManifest.xml file didn't have all the android:exported properties explicitly set. This error is explained further here: https://developer.android.com/about/versions/12/behavior-changes-12#exported
If your app targets Android 12 or higher and contains activities,
services, or broadcast receivers that use intent filters, you must
explicitly declare the android:exported attribute for these app
components.
Warning: If an activity, service, or broadcast receiver uses intent
filters and doesn't have an explicitly-declared value for
android:exported, your app can't be installed on a device that runs
Android 12 or higher.
After I added the required android:exported properties into AndroidManifest.xml file, the error was resolved.
In your Androidmanifest.xml file at path
app/src/main/Androidmanifest.xml
add android:exported="true"` in activity tag.
Sample:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.example">
<application
android:label="example"
android:icon="#mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize"
android:exported="true">
For those who still might get this error if you have done everything from enabling to flutter clean and all.
I solved this error by checking the manifest and adding proper value because i changed something in the manifest which was not supported and later forgot to change it.
so if you have changed something in theme, drawable or any resource file check that out first.
INSTALL_FAILED_USER_RESTRICTED: Invalid apk
Steps for MIUI 9 and Above:
Settings -> Additional Settings -> Developer options ->
step 1: scroll down side - Turn off "MIUI optimization" and Restart your device.
step 2: Turn On "USB Debugging"
step 3: Turn On "Install via USB"
step 4: show push notification and just click USB - Set USB Configuration to Charging (MTP(Media Transfer Protocol) is the default mode.
Works even in MTP in some cases).
please try.
If you are targeting android 'P' then your build.gradle file should look like this
android {
compileSdkVersion 'android-P'
defaultConfig {
applicationId "xyz.com"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
}
buildTypes {
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
targetSdkVersion must be 27 to run your app below android 'P', otherwise the app can only run on 'P' and above.

Issue running more than one NativeScript application on the same android device with tns run

NativeScript 2.0.0, Windows 10
When trying to run more than one NativeScript application on the same android device the tns run android command stops with message:
Successfully deployed on device with identifier '192.168.99.100:5555'.
The application is not installed.
After some investigation, I tried to install the app on the android device using adb directly:
adb "-s" "192.168.99.100:5555" "install" "-r" "<path to apk>.apk"
The command responds with the following:
961 KB/s (15394490 bytes in 15.642s)
WARNING: linker: /system/lib/libhoudini.so has text relocations. This is wasting memory and prevents security hardening. Please fix.
pkg: /data/local/tmp/<app name>-debug.apk
Failure [INSTALL_FAILED_CONFLICTING_PROVIDER]
After some investigation on INSTALL_FAILED_CONFLICTING_PROVIDER and found the following links:
https://issues.apache.org/jira/browse/CB-10014
https://code.google.com/p/analytics-issues/issues/detail?id=784
Install shows error in console: INSTALL FAILED CONFLICTING PROVIDER
I can say it's an ugly problem.
Researching some more, in the NativeScript project, in the directory \platforms\android\build\intermediates\exploded-aar\com.google.android.gms\play-services-measurement\8.4.0 directory there is a manifest template that contains:
<provider
android:authorities="${applicationId}.google_measurement_service"
android:name="com.google.android.gms.measurement.AppMeasurementContentProvider"
android:exported="false"/>
But applicationId is never defined, so when more than one app with this provider is added, the second one fails to install.
I have multiple NS apps installed on my phone and emulators; however when you create a new app; check to see if somehow you have ended up with the same internal name. (This can easily happen if you duplicate your prior project)
Open up your main/primary package.json file that resides in the outermost root of your project folder.
Inside this package.json file you should have a key:
"nativescript": {
"id": "org.nativescript.test3",
"tns-android": {
"version": "2.0.0"
}
},
The "id" is the underlying name of the app that will be installed on the phone. In this case; this is the awesome "org.nativescript.test3" project.
If you get duplicate id's then the the app will overwrite the each other when deployed.
There is a second reason this can happen, and the actual cause of this issue was figured out by the author of the question also. But I will stick here for any future people who might run into this so that we have a valid answer.
The author was using Google Play Services plugin, it has a AppMeasurementContentProvider that if you don't have a applicationId set in your configuration it will default to a blank id; which then means it will conflict with any other app that is using GPS that also doesn't have a applicationId set.
The real nastyness of this bug is that it will conflict with ANY app from ANY other developer who also left their applicationId blank. And so then only ONE of the apps would be installable; any other app that has a blank applicationId would not be installable on that device.
The solution is to open up your /app/App_Resources/Android/app.gradle file and we will add a new value to it.
The current version as of NativeScript v2.00 looks something like this:
android {
defaultConfig {
generatedDensities = []
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
}
If you recall the first part of this answer and about duplicate ids; the package.json we referenced gives you the name you want to use. So in my case I would add to the
defaultConfig {
applicationId = "org.nativescript.test3"
}
So the final file should look something like this:
android {
defaultConfig {
generatedDensities = []
applicationId = "org.nativescript.test3"
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
}
This is related to:
Install shows error in console: INSTALL FAILED CONFLICTING PROVIDER
https://code.google.com/p/analytics-issues/issues/detail?id=784
This workaround worked for me:
in the app/App_Resources/Android/AndroidManifest.xml file add:
<provider
tools:replace="android:authorities"
android:name="com.google.android.gms.measurement.AppMeasurementContentProvider"
android:authorities="MY_APPLICATION_ID.gms.measurement.google_measurement_service"
android:exported="false" />
Where MY_APPLICATION_ID is the application's package (put it manually because __PACKAGE__ didn't work)
Don't forget to declare de tools namespace:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="__PACKAGE__" ...>

Is there an easy way to have a test version of an app and a release version installed on an android phone?

Say I have a production version com.android.xyz and this is production
then I am developing something and i want to load both this version and the production version on my phone so it's side by side. I know I can create a new package like com.android.abc and then I would have a second app which is basically a clone of com.android.xyz.
Thoughts?
Thanks in advance,
Reid
IF you are using Android Studio with Gradle, there is an easy way to do this. I still keep the the same packageName in AndroidManifest.xml (at least current gradle needs this duplicate definition)
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:installLocation="internalOnly"
package="com.android.xyz">
build.gradle
def devBuildName = "dev"
def testBuildName = "test"
android {
defaultConfig {
versionCode 70
versionName "2.2.3"
minSdkVersion 10
targetSdkVersion 19
packageName "com.android.xyz"
}
buildTypes {
debug {
packageNameSuffix "."+devBuildName
versionNameSuffix "-"+devBuildName.toUpperCase()
}
test.initWith(buildTypes.debug)
test {
packageNameSuffix "."+testBuildName
versionNameSuffix "-"+testBuildName.toUpperCase()
}
}
}
You can look at my full dev/release example at github.
You need to change the package name. IMO the easiest way to do this is by writing a perl/python script to iterate through the files and change the package name based on the build type. Or run a C style macro preprocessor over the files first.

google play application upload failed

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"
}
}

Categories

Resources