7

Using app bundles and play app signing is currently the way recommended by google to deploy new apps on google Play. And starting from August 2021 new apps will be strong-armed into using these formats.

How do I set this up in Unity, and how do I configure the app in Google Play?

4 Answers 4

24

I haven't gotten 2019.4 app bundle builds to sucessfully upload to play console, so it's probably a good idea to upgrade to the 2020.3 LTS before you start (as that's what finally worked for me.

Configuring Google Play App signing

First create a new app in Play Console, give it a name, accept terms etc.

Then, click Internal testing on the menu on the left side, and create a new internal release.

In the first question, click Change App Signing key, Use a different key and then select the third option, where you can upload your existing key (and an optional step with to add an upload key) to Google Play.

Don't follow these instructions

Now, don't just follow the instructions listed on Google Play, as you will end up with an upload key store that Unity doesn't know how to deal with.

Instead, using Unity, we will create two key stores and two keys. The first one is the app signing key, which you will only need to see once when uploading it to Google Play, then Google will take care of it and use it to do the final signing of your apps after you've uploaded your app bundles.

Go to Player settingsPublishing SettingsKeystore ManagerCreate new in dedicated location

open the keystore manager in unity

You don't need to fill out everything. Just the password, key alias and key password. It doesn't matter what you call the key. Don't configure Unity to use this key just yet (we'll create another key and keystore for Unity to use shortly).

Create a app key and key store

Follow instructions 1.-3. on Google Play to upload this new key using the pepk tool.

Then, you need to create an upload key and keystore. Unity will use this key to sign your app bundles. Again, do NOT use the instructions on Google Play to create this key, instead use the Unity UI to create another key store that plays nice with Unity.

The passwords and alias could be whatever you want I named my key uploadkey, but make sure to keep the key store and passwords somewhere safe, you will need these later, or you'll have to create new keys and talk to Google support to reset it.

When prompted, click yes to configure your project to use this new key.

use the new upload key for signing your project

When you've created the key store and key export its public key to the .pem format...

keytool -export -rfc -keystore upload.keystore -alias uploadkey -file upload_certificate.pem

...and upload it to Google Play.

Click Update and then Continue in Play Console.

Play store should now be ready to accept your .aab files.

Configuring Unity

Hopefully, your project is now set up to sign using the upload key you just created.

Make sure to set the package name yourself by going to Player SettingsOther Settings Override Default Package Name . Type in something appropriate in lower-case characters only, the default package name has uppercase characters, which I think is just begging for problems. You can't change this later, or you'll have to create a new play store entry, so make sure it's something that's acceptable for customers to see, i.e. com.yourcompany.gamename.

package name

It's also a good idea to enable 64-bit builds in player settings otherwise, google play will complain later. Switch Scripting Backend to IL2CPP and then tick ARM64:

enable 64-bit builds

Tick Build App Bundle in Build Settings.

build app bundle in build settings

Click Build and build your .aab file

Then upload it to the Google Play Console:

upload to google play

If you're lucky, everything went smoothly, and you can click save and be ready to start testing your app.

If not, you may get helpful error messages, in which case just follow them, if not and they're really non-descriptive (like "Couldn't upload. Try again."), then try temporarily uploading an .apk instead, as that sometimes gives better error messages, then switch back to .aab when you've solved the issue.

1
  • Can you elaborate on what type of problems non-lowercase package names can bring?
    – HyperBrid
    Commented Dec 2, 2023 at 7:46
2

In Unity 2020.3 you can use a jks upload key in Unity that was generated in Android Studio and keep "Let Google manage your key..." selected.

To generate a key, install Android Studio and create an empty Android Studio project then once gradle settles down, choose Build > Generate Signed Bundle. When it prompts for a keystore, create a new one and save it where you want. Cancel out, then in Unity select the jks you saved as your keystore in publishing settings.

You should be able to generate an aab package in Unity using the jks as a custom keystore to upload and still let Google manage the signing key like they recommend.

2

FOR ALL YOU BEAUTIFUL FOLK WHO GET STUCK AT THE LAST STEP! - READ THIS!

Blockquote When you've created the key store and key export its public key to the .pem format...

keytool -export -rfc -keystore upload.keystore -alias uploadkey -file upload_certificate.pem

...and upload it to Google Play.

Blockquote

Click Update and then Continue in Play Console.

THIS part drove me NUTS trying to figure out what the hell you meant by that. I know it's down to the fact that I'm a complete noob at this but the rest of the tutorial was AMAZING!

So let me clarify for those newbies (like me) who might lose the plot when they get to the last step and can't figure out what the hell to do.

At this point in the tutorial:

Blockquote and upload it to Google Play. Click Update and then Continue in Play Console.

Here is what you have to do.

  • If you have already uploaded the FIRST signing key you were asked to make in unity (NOT the upload one), then simply go back to the INTERNAL TESTING page and refresh it.

  • Click CHANGE APP SIGNING KEY and then select the third option again: "Export and upload a key from Java keystore"

  • Click UPLOAD GENERATED ZIP and upload the .zip file that was created during the first steps.... I named mine output.zip

  • At STEP 4 you will see a link called "SHOW INSTRUCTIONS" - Click the link and upload your public upload certificate that was generated in the last step. The file ending with the .pem format

  • Click SAVE and it should work.

NOW the next part got me. I didn't know what to do from here. The project is ready to accept the .aab files but DO NOT DO THIS JUST YET!

Learn from Mr Impatient himself (that's me), read the rest of the tutorial. Changing the file name to all lowercase is good practice to prevent issues later with CamelCaseFileNames.

FINALLY

You might get an error that says your target Android API is too low. Simply go to the UNITY PROJECT > FILE > BUILD SETTINGS > PLAYER SETTINGS > OTHER SETTINGS > and half way down the page change MINIMUM API LEVEL to "31" or above as instructed by the Google Prompt you WILL get if you ignore this :)

You can do this through Unity, it will download the latest version of the Android SDK (it opens a powershell terminal - DO NOT CLOSE THIS).

Once that's done, and you've completed all the steps listed above, then and ONLY THEN are you ready to compile your .aab file and upload it to the Google Play Console.

Finally, I want to thank the author of this tutorial BobbaLuba for his amazing efforts. After 7 hours of messing around in Unity -> Android Studio -> Google Play and almost abandoning the thought of releasing my app on Google .... it worked!

You are amazing sir. I tip my hat to you. Keep doing what you do. I for one, am eternally grateful .... I am emotionally, mentally and physically drained. I'm off to bed. Thanks again!

Good luck my little code monkeys!
Peace out

- NewbNinja

0

After struggling with uploading an app bundle, I realized one extra thing :

Don't use any forbidden characters in your password for the keystore in Unity ! This includes spaces and brackets, maybe not only...

If in doubt, try creating the key with Java keytool command line and it will tell you your password contains characters that can't work... Even just type the command line into a terminal and you'll see your password makes the command line break !

keytool -genkey -keystore yourfile.jks -dname "n=Mark Jones, ou=JavaSoft, o=Sun, c=US" -alias android -keypass YOUR PASSWORD  -storepass YOUR PASSWORD -keyalg RSA -keysize 2048 -validity 2000

Maybe special chars are allowed in the Unity key generation panel but not in keytool ! Unity should fix this issue, it was driving me nuts ;)

Peace :)

Not the answer you're looking for? Browse other questions tagged or ask your own question.