Getting an App Bundle together for Play Store


We first came across the App Bundle system, when we got prompted by Google Play to update our previous game to have a 64-bit build for newer Android devices. This seemed to be a very nice system: we provide a bundle, Google then builds up a suitable APK for the end user's device, minimizing download size. And to accommodate for Google's quite strong recommendations to always use App Bundles, Unity can now build those for us. However, it wasn't quite as easy as it could have been... And hence: this tutorial, so that others might learn from our mistakes!

First of all, you need at least Unity 2018.3 to get the App Bundle option in build settings. We shifted to 2019.1.6 since it was the most recent stable version at the time. What should be noted about upgrading to this particular Unity version you might run into the following problems:

- if you get plenty of CS1644 errors from TextMeshPro or other components, your best bet is to go to Project Settings -> Player -> Other Settings and switch the .NET to 4.x, that'll fix those pesky reds

- Error CS1029: "The Data Privacy Plugin is included in the Analytics Library Package and is no longer needed. Please remove this plugin" -> remove the old Data Privacy plugin and make sure you have at least 3.1.1 version of the Analytics Library (check from Package Manager)

A lot of *DK's

If you've built for Android before, you should already have JDK installed and Android SDK for the target platforms. If your SDK Tools are old, Unity will prompt you to download the new ones when building so this isn't much of an issue

However, you might not have the NDK, native developer kit, which is needed in order to build with IL2CPP backend, which in turn is needed for the 64-bit build. This one was a bit hard to find, as simply checking the "Android NDK installed with Unity" box didn't work for us.

At first, I installed the latest NDK available, but it didn't play well with Unity, so after a bit of googling, we got a slightly older version, Android NDK, Revision 16b (December 2017), from the NDK archives. After installing it, it needed to be linked to Unity's Settings.

Configuring the backends

Then, we'll have to play around with the Project Settings (-> Player -> Other Settings):

- Configuration, Scripting Runtime should by now be 4.x

- Configuration, Scripting Backend needs to be switched to IL2CPP, since we need this to build the 64-bit version of the native code

- Configuration, Api Compatibility Level needs to be .NET 4.x

- Configuration, Target Architectures, check the ARM64 box

- Identification, select the target platform and the minimum platform. Note that the minimum platform requirements are often updated by Google. As of now, the minimum can't be lower than API level 23.

- Identification, also check that you update the version number and Bundle Version Code. Play Store won't accept the bundle if it has the same code as a previous version. Also, if you do upload a bundle, but the release fails (for instance, if it detects that it isn't 64-bit compatible) and you need to re-upload it, it still needs a new version code...

Getting your keys straight

Also, for the app to be signed for release, you'll need to give your developer key in Player -> Publishing Settings. If you don't already have a key for your company, you can make one with Android Studio. I recommend opting into Google's app signing, but you still need a key to verify your app to any further updates for your game. But there are good instructions for it from Google

In the end, you should have a Keystore file, which contains your signing keys. In the publishing settings Project Keystore section, you'll have to browse to find your keystore (keep it safe, on some other folder on your machine than the Unity project folder) and access it using that first password you determined when creating the keystore. Then in the Project Key section, select your key from the dropdown (it'll update once the first password is cleared) and give the password for that key.

And then the finale!

Now, finally, we can go to the actual Build Settings (via File -> Build Settings). Switch the platform to Android and check the checkbox next to 'Build App Bundle (Google Play)'. Browse to find a suitable folder where to build your app (personally I use a folder outside the Unity project and name it 'Bundle Builds' or something similar) and give it a name. The name is trivial, but I recommend using something that has version numbering. Then, click OK and wait for the building to start. If you get a warning message, follow its instructions. Usually, it's either missing SDK Tools (which Unity can download for you), missing cert key (make sure you've given the passwords, they reset on every restart) or something else quite easy to fix, so don't fret! :) And then waaaaait for a looooong time for the build to finish...

And once you have that precious .AAB bundle file, you can upload it to Developer Console. On the first page of the upload process, you can drag-n-drop the bundle file and let Google chew on it for a while. If you get an error at this point, it is most likely to do with your keys, but the error messages are quite helpful to point you to the right direction. Sadly, it won't clearly tell you at this point whether your bundle is 64-bit compliant... You can see it from the info just under the dropbox, if you click on the expand arrow next to your newly updated bundle. On the last row, it says how many and which client environments are supported. It should list at least arm64-v8a and armeabi-v7a. If you see only the v7, then your bundle didn't have a 64-bit version included and it's most likely due to configuration settings (first check that you have .NET 4.X everywhere). When you go to the next page of the publishing, it will give you a very nice red-flagged warning about it though, so you can't really miss it at that point.

Well, I hope you now got your bundle ready and error-free! Just keep calm and ask in the comments if you get stuck somewhere! I don't pretend to be any kind of an expert, but having struggled with this so many times now, I think I can at least point you in the right direction. Good luck!

Get Anxiety of Alina

Buy Now$1.99 USD or more

Leave a comment

Log in with itch.io to leave a comment.