title: APK version code conflict despite Google Play Store showing otherwise
body: <p>I am using fastlane to automatically increment my version code and deploy my app. I am getting the error <code>apkNotificationMessageKeyUpgradeVersionConflict: APK specifies a version code that has already been used. - APK specifies a version code that has already been used</code> despite the highest versionCode of my releases is 3.</p>
  
  <p><strong>Lane<code>bump_version_code</code> executing</strong></p>
  
  <pre><code>[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' 
  </code></pre>
  
  <p><strong>Lane context and error</strong></p>
  
  <pre><code>+-------------------------------------+-------------------------------------------------------------------------------------------------------------------+
  | 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           |
  +------+------------------------------------------+-------------+
  </code></pre>
  
  <p><strong>Fastfile</strong></p>
  
  <pre><code>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" =&gt; ENV["ANDROID_KEYSTORE"],
          "android.injected.signing.store.password" =&gt; ENV["ANDROID_KEYSTORE_PASSWORD"],
          "android.injected.signing.key.alias" =&gt; ENV["ANDROID_KEY_ALIAS"],
          "android.injected.signing.key.password" =&gt; ENV["ANDROID_KEY_PASSWORD"],
        }
      )
      upload_to_play_store(track: 'alpha')
    end
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/7vOVD.png" rel="noreferrer"><img src="https://i.stack.imgur.com/7vOVD.png" alt="enter image description here"></a></p>
  
  <p><strong>Archive library</strong></p>
  
  <p><a href="https://i.stack.imgur.com/cIPKt.png" rel="noreferrer"><img src="https://i.stack.imgur.com/cIPKt.png" alt="enter image description here"></a></p>