Creating Android App Bundles (aab) with Unity Cloud Builds

Is it possible to create the new Android App Bundles with Unity Cloud builds?

5 Likes

bump, this would be a really strong feature to have (and considering it’s part of the unity gradle builds since 2018.3, shouldn’t be that hard to implement)

1 Like

Bump. I would also like an option for this for builds run from batchmode

I am also very interested in knowing this. Can anyone from Unity Cloud Build support give us a hint if there is a roadmap for this?

Any news on this? Currently, I can create all builds on the cloud but for an Android release, I have to build locally which isn’t an ideal situation.

1 Like

I don’t have tested yet, and don’t know if it’s the intended behavior for Unity Cloud Build but you can find the bool at editor level here:

using UnityEditor;

EditorUserBuildSettings.buildAppBundle = true;

Also see the other recommendations here: Unity - Scripting API: EditorUserBuildSettings.buildAppBundle

You may try to execute a PreBuild custom method on your Unity Cloud Build project in order to reconfigure the UnityEditor configuration, and see what happen.

I’ve done something similar in order to Add/Remove OpenVR/Oculus SDK depending if the build is intended for Oculus Store shipping or for Steam.

1 Like

I gave it a try and the build did succeed, however, Unity Cloud says there is no download available.
So I guess it doesn’t recognize the aab file as a downloadable output.

It’s possible, but there is an option to override Unity Cloud Build output files no ?
Didn’t have tested yet !

EDIT: Must have dreamed ! You are right, you cannot explore or redirect anything from the standard interface.

I think Unity don’t support this option yet…
It seem that Unity is looking for an APK file for Unity Cloud Build shipping.

You may try to fool the system with a PostBuild script, and renaming the application Bundle as an APK, but i don’t even know if it would works.

I think the Unity Cloud Build Team must uprade theirs infrastructure for this scenario…

Thanks, it was a good suggestion. But fooling the system seems to go a little too hacky :smile:
I’ll wait for Unity to properly implement it.

Bump

Bump

I agree this would be an awesome feature to have.

Hi all!

We ran into the same issue and decided to go with the way of using pre- and post-export methods to cheat Unity Cloud to build and export an App Bundle file.

This editor script will configure Unity Cloud to build the App Bundle and finally to rename the .aab file to .apk so it can be downloaded. The downloaded file will be an App Bundle even though it is named as .apk and you can later rename it to .aab.

To use this editor script you need to configure the pre and post build methods under your Unity Cloud build config. Under Advanced Options you can configure Pre-Export Method Name and Post-Export Method Name. Remember to include the namespace name, for example: YourNamespace.AppBundleUnityCloudUtil.OnPreExport.

App Bundle files can be converted to .apks files that can be installed to a device for local test. Converting and installing can be done using Google’s bundletool. Help on how to download and use this tool can be found in the references below.

Editor script:

#if UNITY_CLOUD_BUILD
using System.IO;
using UnityEngine;

namespace YourNamespace
{
    public static class AppBundleUnityCloudUtil
    {
        public static void OnPreExport()
        {
            UnityEditor.EditorUserBuildSettings.buildAppBundle = true;
            Debug.Log("AppBundleUnityCloudUtil: Enabled building of an Android App Bundle");
        }

        public static void OnPostExport(string exportPath)
        {
            if (!UnityEditor.EditorUserBuildSettings.buildAppBundle)
            {
                Debug.LogErrorFormat("AppBundleUnityCloudUtil: UnityEditor.EditorUserBuildSettings.buildAppBundle is not enabled");
            }

            var bundlePath = exportPath.Replace(".apk", ".aab");
            if (File.Exists(bundlePath))
            {
                Debug.LogFormat("AppBundleUnityCloudUtil: Moving {0} to {1}", bundlePath, exportPath);
                File.Move(bundlePath, exportPath);
            }
            else
            {
                Debug.LogErrorFormat("AppBundleUnityCloudUtil: AppBundle file not found in path {0}", bundlePath);
            }
        }
    }
}
#endif

References:

6 Likes

Awesome, this is indeed working! And it actually looks simpler then I had imagined.
Thanks!

Great hack but we still need to push for full support

4 Likes

Would like to express my interest here too. We had several issues using OBB file, when we tried the aab, it worked flawlessly, which means that this is our only way of exporting our vuforia project without issues.

We desperatly need this feature.

Would also be great to have a date to expect this implemented, it would really speed things up.

1 Like

Bump

Hey, can we have an official answer about that ? App bundles can be generate since 2018.3, it does not seems such a huge feature to just recognize abb instead of apk …

1 Like

I don’t mind using the hack for now but this should be part of cloud build imo.

Unfortunately the “hack” is not working also (at least for me). I’m getting the error that written in the line 31 of the hack - file not found. AAB is built for sure - the logs and the missing download file on a successful build indicate it.

AppBundle file not found in path /BUILD_PATH/here-was-companyname.and.app.bundle/temp.XXXXXX20190526-6564-1xkdmdg/Droid Dev.aab

Can someone confirm that the hack is still working for them? May be it’s connected to the Unity version I’m building with? I’m using 2018.3.14f1

And yes, I would love Cloud Build devs to implement AAB on their side. The platform already building, all that remains is to take “.aab” extension into account.