Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

APK version code conflict despite Google Play Store showing otherwise

Tags:

fastlane

I am using fastlane to automatically increment my version code and deploy my app. I am getting the error apkNotificationMessageKeyUpgradeVersionConflict: APK specifies a version code that has already been used. - APK specifies a version code that has already been used despite the highest versionCode of my releases is 3.

Lanebump_version_code executing

[03:47:41]: ------------------------------
[03:47:41]: Driving the lane 'android alpha' 🚀
[03:47:42]: ------------------------------------------------------
[03:47:42]: --- Step: Switch to android bump_version_code lane ---
[03:47:42]: ------------------------------------------------------
[03:47:42]: Cruising over to lane 'android bump_version_code' 🚖
[03:47:42]: ---------------------------------------------
[03:47:42]: --- Step: google_play_track_version_codes ---
[03:47:42]: ---------------------------------------------
[03:47:43]: Found '1' version codes in track 'production'
[03:47:43]: ---------------------------------------------
[03:47:43]: --- Step: google_play_track_version_codes ---
[03:47:43]: ---------------------------------------------
[03:47:45]: Found '1' version codes in track 'beta'
[03:47:45]: ---------------------------------------------
[03:47:45]: --- Step: google_play_track_version_codes ---
[03:47:45]: ---------------------------------------------
[03:47:46]: Found '3' version codes in track 'alpha'
[03:47:46]: ------------------------------------
[03:47:46]: --- Step: increment_version_code ---
[03:47:46]: ------------------------------------
[03:47:46]: The get_version_code plugin is looking inside your project folder (./app)!
[03:47:46]: ☝️ Version code has been changed to 4
[03:47:46]: Cruising back to lane 'android alpha' 🚘

Lane context and error

+-------------------------------------+-------------------------------------------------------------------------------------------------------------------+
| DEFAULT_PLATFORM                    | android                                                                                                           |
| PLATFORM_NAME                       | android                                                                                                           |
| LANE_NAME                           | android alpha                                                                                                     |
| VERSION_CODE                        | 4                                                                                                                 |
| GRADLE_BUILD_TYPE                   | Release                                                                                                           |
| GRADLE_ALL_APK_OUTPUT_PATHS         | ["/Users/runner/runners/2.165.2/work/myapp/myapp/client/android/app/build/outputs/apk/release/app-release.apk"] |
| GRADLE_ALL_AAB_OUTPUT_PATHS         | []                                                                                                                |
| GRADLE_ALL_OUTPUT_JSON_OUTPUT_PATHS | ["/Users/runner/runners/2.165.2/work/myapp/myapp/client/android/app/build/outputs/apk/release/output.json"]     |
| GRADLE_ALL_MAPPING_TXT_OUTPUT_PATHS | []                                                                                                                |
| GRADLE_APK_OUTPUT_PATH              | /Users/runner/runners/2.165.2/work/myapp/myapp/client/android/app/build/outputs/apk/release/app-release.apk     |
| GRADLE_OUTPUT_JSON_OUTPUT_PATH      | /Users/runner/runners/2.165.2/work/myapp/myapp/client/android/app/build/outputs/apk/release/output.json         |
+-------------------------------------+-------------------------------------------------------------------------------------------------------------------+
[03:49:53]: Google Api Error: apkNotificationMessageKeyUpgradeVersionConflict: APK specifies a version code that has already been used. - APK specifies a version code that has already been used.

+------+------------------------------------------+-------------+
|                       fastlane summary                        |
+------+------------------------------------------+-------------+

| Step | Action                                   | Time (in s) |
[!] Google Api Error: apkNotificationMessageKeyUpgradeVersionConflict: APK specifies a version code that has already been used. - APK specifies a version code that has already been used.
+------+------------------------------------------+-------------+
| 1    | default_platform                         | 0           |
| 2    | Switch to android bump_version_code lane | 0           |
| 3    | google_play_track_version_codes          | 1           |
| 4    | google_play_track_version_codes          | 1           |
| 5    | google_play_track_version_codes          | 1           |
| 6    | increment_version_code                   | 0           |
| 7    | clean                                    | 47          |
| 8    | assembleRelease                          | 73          |
| 💥   | upload_to_play_store                     | 5           |
+------+------------------------------------------+-------------+

Fastfile

lane :bump_version_code do
    g = google_play_track_version_codes
    gb = google_play_track_version_codes(track: 'beta')
    ga = google_play_track_version_codes(track: 'alpha')
    max_value = [g[0].to_i, gb[0].to_i, ga[0].to_i].max
    version_updated = max_value + 1
    increment_version_code(
      app_folder_name: "./app", 
      version_code: version_updated.to_i
    )
  end

  desc "Submit a new Alpha Build to Google Play"
  lane :alpha do
    bump_version_code
    gradle(task: 'clean')
    gradle(
      task: 'assemble',
      build_type: 'Release',
      properties: {
        "android.injected.signing.store.file" => ENV["ANDROID_KEYSTORE"],
        "android.injected.signing.store.password" => ENV["ANDROID_KEYSTORE_PASSWORD"],
        "android.injected.signing.key.alias" => ENV["ANDROID_KEY_ALIAS"],
        "android.injected.signing.key.password" => ENV["ANDROID_KEY_PASSWORD"],
      }
    )
    upload_to_play_store(track: 'alpha')
  end

enter image description here

Archive library

enter image description here

like image 310
user82395214 Avatar asked Mar 24 '20 03:03

user82395214


2 Answers

Go to Google Play Console

  • "App bundle explorer" in the sidebar
  • top right corner, click on the "App version: *** ▾"
  • you should see all the uploaded bundle. Delete the one that have the version code you want to use.

Explanation: this happened to me while playing with Fastlane. I uploaded a bunch of .aab files and the versionCode was updated all the time (I was toying with increment_version_code plugin so this make sense). I ended up pushing a build by hand because I got an error (that has nothing to do with versionCode). After a few days, I tried to continue working on that and wanted to upload my build "3" (versionCode: 3, as I only pushed 2 bundles in testing, the others where unused)... But during my previous days, I upload three builds 3, 4 and 5, that were causing the issue. Deleting them allowed me to push a new build with versionCode 3.

like image 50
MoOx Avatar answered Jan 02 '23 06:01

MoOx


This is because you have some artifact uploaded on the artifact library that has been uploaded manually. If you delete it it will work. You can find the Artifact Library on the left menu, inside release management.

enter image description here

Probably there will be some draft binaries uploaded with a code version bigger than the ones on the active ones.

like image 43
rcarba Avatar answered Jan 02 '23 07:01

rcarba