Search Unity

Android Build Options Suggestion

Discussion in 'Editor & General Support' started by Gillissie, Nov 12, 2021.

  1. Gillissie

    Gillissie

    Joined:
    May 16, 2011
    Posts:
    305
    Please move the keystore-related stuff from the Player Settings to the Build Settings.
    Every time you relaunch Unity, you have to enter the keystore passwords before making an Android build. Why have the fields buried?

    Inevitably, I forget to type them in before the first build attempt. If the section was right there in the build settings, it would be easy to remember to type them in before building the first time, and we wouldn't have to dig into the player settings to do it.

    To me, the Player Settings are things that are essentially "set and forget". Having to enter data into the Player Settings section every time you make the first build after re-loading the project doesn't fit this idea.

    I've attached a mockup of this idea...
    Build Settings.jpg
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,745
    I appreciate your thinking on this, but since you MUST update the bundle version code anyway (or the build # in iOS), I just have a standard checklist of stuff to do in PlayerSettings before I cut a build.

    And when building for TV often you make two bundles per build anyway, one with LEANBACK intent, one without.
     
  3. Gillissie

    Gillissie

    Joined:
    May 16, 2011
    Posts:
    305
    "MUST" isn't accurate at all. There's a few reasons it's not a MUST to update version values every time you build.
    1. Sometimes you just need to make a build to test, and you're not worried about the version value yet.
    2. Sometimes you have already updated the version number in a previous session, but you still have to enter the passwords.
    3. For some projects, I use script to automatically update all version numbers when building. In one project of mine, I update version numbers when building for iOS, but not for Android. This lets me build for iOS first, then build for Android, and it keeps both bundle versions in sync. The only version value I manually change is the middle value at the top of player settings (not buried in "other settings" below it). For example, version 1.23.100 would automatically change to 1.23.101 during an iOS build. I only manually change the "23" part of it to "24" if the update is worthy of the increment.

    Basically, I'm talking about using the Build Settings window to make builds manually. All of this can be scripted to be done automatically, and that's great. But not everyone does that for every project.

    This works for me to avoid the hassle:
    Code (CSharp):
    1. public void OnPreprocessBuild(BuildReport report)
    2. {
    3. #if UNITY_ANDROID
    4.     PlayerSettings.Android.keystoreName = ANDROID_KEYSTORE_NAME;
    5.     PlayerSettings.Android.keystorePass = ANDROID_KEYSTORE_PW;
    6.     PlayerSettings.Android.keyaliasName = ANDROID_KEY_NAME;
    7.     PlayerSettings.Android.keyaliasPass = ANDROID_KEY_PW;
    8. #endif
    9. }
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,745
    Fair enough... are you aware you don't always need the signing key for local builds? The default debug signing key will work just fine for a large portion of on-device testing. All you need to do is choose the keystore and then cancel.

    The previous binary WILL need to be removed from device first, then you can Ctrl-B rapido-build to device again and again, never changing the bundle version code, never signing it with your actual key.

    I think there's even some feature that appeared at some point where it ONLY recompiles the C# scripts, not rebuilding all the bag of assets, and regenerates the APK from that.