Search Unity

(Resolved) cloud build ignores AndroidBundleVersionCode

Discussion in 'Unity Build Automation' started by rzubek, Dec 27, 2017.

  1. rzubek

    rzubek

    Joined:
    Aug 21, 2014
    Posts:
    72
    When I run an Android build on Cloud Build, it ignores "AndroidBundleVersionCode" in project settings, and replaces it automatically with the cloud build number, for example, "18" (but it gets automatically incremented). Then when we upload the APK to the Google Play Store, it causes an automatic rejection with the error message "Upload failed. You need to use a different version code for your APK because you already have one with version code 18."

    DETAILS

    Specific example: a recent build was run on cloud build, using "Latest Unity 2017.2" (in this case: Unity 2017.2.1f1 - but it doesn't matter if I set the unity version to "Latest 2017.2" or some specific, older 2017.2 patch version).

    The project specifies the following bundle information in ProjectSettings.asset:
    bundleVersion: 0.9.0
    buildNumber:
    iOS: 1
    AndroidBundleVersionCode: 1


    EXPECTED BEHAVIOR: the APK should be built with version "0.9.0" and bundle version "1" as specified in project settings.

    OBSERVED BEHAVIOR: the APK is built with bundle version "18", which is the automated build code of that cloud build run. This is incorrect, and causes failures when uploading to the Google Play Store.

    This only happens on Android, not on iOS builds. iOS builds respect the "buildNumber/iOS" entry in ProjectSettings.

    (Edited to remove irrelevant details.)
     
    Last edited: Dec 28, 2017
  2. rzubek

    rzubek

    Joined:
    Aug 21, 2014
    Posts:
    72
    For anyone googling for this behavior in the future, I got this advice which resolves the issue:

    Cloud build only replaces 'bundleVersionCode' if the value that is checked into the player settings is the default value of 1. If it's anything greater than 1, it wont overwrite and there will be a message in the build log:

    Will not override android bundleVersionCode - already set in player settings

    So when upgrading from, say, version 0.8 to 0.9, on iTunes it's okay to reset build number to "1", but on Android it's best to just keep increasing build numbers as if the version hadn't changed. Hope this helps someone in the future!