Build App Bundles (.aab) AND Build Asset Packs with splitbasemoduleassets

I have the google plugin installed and the following pre-export method called

    public static void ConfigureAssetPacks()
    {
        // Creates an AssetPackConfig with a single asset pack, named
        // examplePackName, containing all the files in path/to/exampleFolder.
        AssetPackConfig assetPackConfig = new AssetPackConfig();
        assetPackConfig.SplitBaseModuleAssets = true;

        // Configures the build system to use the newly created assetPackConfig when
        // calling Google > Build and Run or Google > Build Android App Bundle.
        AssetPackConfigSerializer.SaveConfig(assetPackConfig);
    }

Running this causes the build to fail. It was working completely fine when outputting apk + oob but unfortunately google is no longer accepting that format as of August 1st so we’re stuck with the Play Asset Delivery process.

Anyone know why this wouldn’t be building successfully? I’m getting no errors in the log, just a “build failed” after outputting a callstack:

65615: [Unity] UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
65616: [Unity] UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
65617: [Unity] UnityEngine.Logger:LogFormat(LogType, String, Object[])
65618: [Unity] UnityEngine.Debug:LogFormat(String, Object[])
65619: [Unity] Google.Android.AppBundle.Editor.Internal.BuildTools.AppBundleBuilder:BuildAndroidPlayer(BuildPlayerOptions) (at Assets/GooglePlayPlugins/com.google.android.appbundle/Editor/Scripts/Internal/BuildTools/AppBundleBuilder.cs:165)
65620: [Unity] Google.Android.AppBundle.Editor.Internal.AppBundlePublisher:Build(AppBundleBuilder, AppBundleBuildSettings) (at Assets/GooglePlayPlugins/com.google.android.appbundle/Editor/Scripts/Internal/AppBundlePublisher.cs:174)
65621: [Unity] Google.Android.AppBundle.Editor.Internal.AppBundlePublisher:Build(BuildPlayerOptions, AssetPackConfig, Boolean) (at Assets/GooglePlayPlugins/com.google.android.appbundle/Editor/Scripts/Internal/AppBundlePublisher.cs:110)
65622: [Unity] Google.Android.AppBundle.Editor.Bundletool:BuildBundle(BuildPlayerOptions, AssetPackConfig, Boolean) (at Assets/GooglePlayPlugins/com.google.android.appbundle/Editor/Scripts/Bundletool.cs:79)
65623: [Unity] System.Reflection.MonoMethod:InternalInvoke(Object, Object[], Exception&)
65624: [Unity] UnityEditor.CloudBuild.UnityReflector:GooglePlayBuildBundle(BuildPlayerOptions, Object)
65625: [Unity] UnityEditor.CloudBuild.Builder:BuildPlayerGoogle(BuildPlayerOptions)
65626: [Unity] UnityEditor.CloudBuild.Builder:BuildPlayer(BuildPlayerOptions)
65627: [Unity] UnityEditor.CloudBuild.Builder:Build()
65628: [Unity] (Filename: Assets/GooglePlayPlugins/com.google.android.appbundle/Editor/Scripts/Internal/BuildTools/AppBundleBuilder.cs Line: 165)

here’s the full log Dropbox

I have a similar configuration (.aab) + Build Asset Packs + PreBuild script that initializes AssetPackConfig
Unity 2019.4.30
Local build succeeds (using custom build method from google’s package)
but cloud build fails with this error:

[Unity] ERROR: Build error: Failed to locate the Android SDK. Check Preferences -> External Tools to set the path.

Finally I found a workaround.

To resolve “Failed to locate the Android SDK” error call OverrideEditorPreferences() at the beginning of ConfigureAssetPacks method

Google.Android.AppBundle.Editor.Internal.BuildTools.AndroidSdk.OverrideEditorPreferences();

The second thing I had to do is to turn off “Build Asset Bundles” option in cloud build config and call BuildPipeline.BuildAssetBundles manually before AssetPackConfig is being initialized.

1 Like

Been running into the exact same issue. I managed to put in a Google search where the only response in the whole world was your reply right here. Immensely helpful. Dunno how I would have ever known to discover “Google.Android.AppBundle.Editor.Internal.BuildTools.AndroidSdk.OverrideEditorPreferences” on my own. Migrating to PAD-conformant builds is quite the hassle right now (had to do it to rescue our broken Unity Cloud Build automation stack after exceeding 150 MB app size) and the current document link is rather vague / defers to Android docs, which are themselves pretty vague / research-intense.

I’m still not 100% sure what the /intended/ equivalent to Google > Build & Run would be in a UCB context. Right now I’m trying to SaveConfig during the PreExport… and I’m trying to run Bundletool again in a PostExport.

assetPackConfig.SplitBaseModuleAssets = true definitely seems to be the way to go as well. I lost some time trying to define a custom one manually so that it would be explicitly pathed, but, can’t figure out in a hurry how to get it to pick up in a way that also omits it from the outgoing bundle. (Google Play Dashboard still complained about APK size and wouldn’t let me distro.)

As far as I can tell, the manual local-editor Google > Build Android App Bundle is hitting Google’s servers as a 15 MB core download with a 147MB ish Asset Pack, which seems correct. But it always still finds a reason to hate on my UCB-generated artifacts. Wrong size. Not signed. Wrong bundle identifier. (These upload-time errors seem mischaracterized.)

I wish Google would give my app the benefit of the doubt after I embedded a Google plugin into my project in order to try to conform to their own limitations. I am very much trying not to revert to APK+OBB… So for now I am living with being able to distribute local builds. Just wish I knew how to fully address the Cloud Build case, or why the Build Asset Packs config option seems to be harmful in my use-case.