bitrise-steplib / steps-google-play-deploy

MIT License
54 stars 38 forks source link

Failed to upload apk, error: APK specifies a version code that has already been used. #31

Closed laumair closed 6 years ago

laumair commented 6 years ago

Hi.

Thank you for this tool. I am having some difficulty while deploying the apk to playstore. Currently we manually update the version code and version name before triggering the build. Despite the version update I always get Failed to upload apk, error: googleapi: Error 403: APK specifies a version code that has already been used., apkUpgradeVersionConflict

Configuration

 google-play-deploy@1.4.1:
        inputs:
        - mapping_file: android/app/build/outputs/mapping/release/mapping.txt
        - package_name: com.iota.packagename
        - apk_path: "$BITRISE_SIGNED_APK_PATH"
        - service_account_json_key_path: "$BITRISEIO_SERVICE_ACCOUNT_JSON_URL"

I'm really not sure how I can further debug but I do have the versions upgraded in the appropriate files.

I would greatly appreciate any help regarding this.

doomsayer13 commented 6 years ago

Hi @laumair Thank you for reporting an issue, we will check it ASAP

viktorbenei commented 6 years ago

@laumair we could not reproduce this so far when the version codes were good.

Could you please copy paste the build's bitrise.io URL, so that we can check the whole log?

joluet commented 6 years ago

@viktorbenei we're seeing the same issue. This is our build url on Bitrise: https://www.bitrise.io/build/621bc4a221c0303b

viktorbenei commented 6 years ago

Thanks @joluet , we'll look into it ASAP!

trapacska commented 6 years ago

Hey @joluet !

Couldn't get enough info from the log. It seems like that the updated code is not in the build yet, or is it possible that another build were running before? (used to happen that 2 builds started, push and PR). Could you please check that?

If it still not figured out, please contact us on our on-site chat.

trapacska commented 6 years ago

@joluet I close this issue now, if you have any more info or question please feel free to re-open the issue!

Thanks! 🚀

asafda commented 6 years ago

I'm getting the same error In Google Play Console I can see that I only uploaded one APK with version code 1 as beta (manually), and i'm trying to upload another APK with various version codes (reached 30 now), but keep getting this error. @viktorbenei @trapacska @doomsayer13 https://www.bitrise.io/build/809b2d6e06fc2833

Thanks!

asafda commented 6 years ago

Problem solved.

It appears that starting from one of the latest create-react-native-app versions the version code is set in the default config of the build.gradle file.

So doing the following solved my issue: In build.gradle remove the lines that set the versionCode and versionName located under the default config:

android {
  ...
  defaultConfig {
    ...
    versionCode 1
    versionName "1.0"
    ...
  }
}

And in AndroidManifest.xml add those definitions

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="YOUR_PACKAGE_NAME"
    android:versionCode="1"
    android:versionName="1.0">
alexnivanov commented 6 years ago

This is still happening for whether I change versionCode in manifest or cradle.

trapacska commented 6 years ago

Hey @alexnivanov @asafda !

Checked again. In 100% of the cases there is an issue with changing the version of the app rather than this step uploads "wrong" version. This step has no functionality of changing, reading, or doing whatever with version codes. The version codes you see printed in the log is for verbose mode reasons. So if you want to upload the same version that you have in the Play Store then you will receive the same error message.

Closing the issue now, as it still seems to be not an error with the step itself.

Happy Building! 🚀

Ingibjorg commented 6 years ago

@alexnivanov I had the same issue but I solved it by following the solution described here: https://github.com/fastlane/fastlane/issues/4675

The step was trying to upload app-debug.apk instead of app-release.apk. I removed the app-debug.apk file and added a step to clean the project and my problem was solved.

alexnivanov commented 6 years ago

Thank you very much, @Ingibjorg !!! I added gradle(task: "clean") and it works!

akshayjai1 commented 6 years ago

I uploaded the apk file manually after uploading failed through console 5 times https://stackoverflow.com/a/52853585/2761641

rpekarek commented 5 years ago

We are also experiencing this issue, we have several white labels so manually uploading is not a sustainable option. We've updated the version from 169 to 170, 171, and finally 172, each time the production version codes number increases to our current version number under "List track infos". How is this possible? Shouldn't this represent the current version on Google Play?

List track infos
 production versionCodes: [172]
Upload apks or app bundle
Failed to upload apk, error: googleapi: Error 403: APK specifies a version code that has already been 
used., apkUpgradeVersionConflict

| x | google-play-deploy@1.5.1 (exit code: 1)

We also had a couple builds marked as success but did not appear to actually be updated on google play after all. Failing build: https://app.bitrise.io/build/6f360f699c846056 Succeeding build: https://app.bitrise.io/build/dc3185417a87dd72 (Separate white labels, same versions)

fehersanyi-bitrise commented 5 years ago

Hello @rpekarek

Could you try using the Change Android versionCode and versionName step to increment the version code with each build so this error will not come up? well at least I hope.

Dilpenny commented 5 years ago

Go to your gradle files change this in build.gradle file->module:app: versionCode 2 versionName "2.0"

ajithkg commented 4 years ago

Problem solved.

It appears that starting from one of the latest create-react-native-app versions the version code is set in the default config of the build.gradle file.

So doing the following solved my issue: In build.gradle remove the lines that set the versionCode and versionName located under the default config:

android {
  ...
  defaultConfig {
    ...
    versionCode 1
    versionName "1.0"
    ...
  }
}

And in AndroidManifest.xml add those definitions

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="YOUR_PACKAGE_NAME"
    android:versionCode="1"
    android:versionName="1.0">

Thanks. This worked for me.

bali94 commented 4 years ago

android:versionCode="1" android:versionName="1.0"

worked for me thanks you man