Unity split binary android build crashes on start

I’ve been trying to get our game to run on android and running into some issues.

Those have been resolved and I’ve been able to install the game with an .apk and that works just fine.

But google requires us to split the game up before uploading it to the google play store. We built the game into an .apk and an .obb file and after installing it, the game crashes immediately with FMOD errors.

Installation Procedure:

  1. Build the game with split binary option checked
  2. adb install game.apk
  3. adb push main.4.studio.shortsleeve.game.obb /sdcard/Android/obb/studio.shortsleeve.game/

I verify that the obb file is there, then I run the game and get these errors:

09-15 09:49:24.925 21286 24526 E Unity   : NullReferenceException: Object reference not set to an instance of an object.
09-15 09:49:24.925 21286 24526 E Unity   :   at FMODUnity.RuntimeManager.Initialize () [0x00000] in <00000000000000000000000000000000>:0
09-15 09:49:24.925 21286 24526 E Unity   :   at FMODUnity.RuntimeManager.get_Instance () [0x00000] in <00000000000000000000000000000000>:0
09-15 09:49:24.925 21286 24526 E Unity   :   at FMODUnity.RuntimeManager.LoadBank (System.String bankName, System.Boolean loadSamples) [0x00000] in <00000000000000000000000000000000>:0
09-15 09:49:24.925 21286 24526 E Unity   :   at Audio.FMODSound.HandleLoadBank (System.String bank) [0x00000] in <00000000000000000000000000000000>:0
09-15 09:49:24.925 21286 24526 E Unity   :   at Audio.FMODSound.OnEnable () [0x00000] in <00000000000000000000000000000000>:0
09-15 09:49:24.925 21286 24526 E Unity   : Rethrow as SystemNotInitializedException: [FMOD] Initialization failed
09-15 09:49:24.925 21286 24526 E Unity   :   at FMODUnity.RuntimeManager.get_Instance () [0x00000] in <00000000000000000000000000000000>:0
09-15 09:49:24.925 21286 24526 E Unity   :   at FMODUnity.RuntimeManager.LoadBank (System.String bankName, System.Boolean loadSamples) [0x00000] in <00000000000000000000000000000000>:0
09-15 09:49:24.925 21286 24526 E Unity   :   at Audio.FMODSound.HandleLoadBank (System.String bank) [0x00000] in <00000000000000000000000000000000>:0
09-15 09:49:24.926 21286 24526 E Unity   : NullReferenceException: Object reference not set to an instance of an object.
09-15 09:49:24.926 21286 24526 E Unity   :   at FMODUnity.RuntimeManager.Initialize () [0x00000] in <00000000000000000000000000000000>:0
09-15 09:49:24.926 21286 24526 E Unity   :   at FMODUnity.RuntimeManager.get_Instance () [0x00000] in <00000000000000000000000000000000>:0
09-15 09:49:24.926 21286 24526 E Unity   :   at FMODUnity.RuntimeManager.LoadBank (System.String bankName, System.Boolean loadSamples) [0x00000] in <00000000000000000000000000000000>:0
09-15 09:49:24.926 21286 24526 E Unity   :   at Audio.FMODSound.HandleLoadBank (System.String bank) [0x00000] in <00000000000000000000000000000000>:0
09-15 09:49:24.926 21286 24526 E Unity   :   at Audio.FMODSound.OnEnable () [0x00000] in <00000000000000000000000000000000>:0
09-15 09:49:24.926 21286 24526 E Unity   : Rethrow as SystemNotInitializedException: [FMOD] Initialization failed
09-15 09:49:24.926 21286 24526 E Unity   :   at FMODUnity.RuntimeManager.get_Instance () [0x00000] in <00000000000000000000000000000000>:0
09-15 09:49:24.926 21286 24526 E Unity   :   at FMODUnity.RuntimeManager.LoadBank (System.String bankName, System.Boolean loadSamples) [0x00000] in <00000000000000000000000000000000>:0
09-15 09:49:24.926 21286 24526 E Unity   :   at Audio.FMODSound.HandleLoadBank (System.String bank) [0x00000] in <00000000000000000000000000000000>:0
09-15 09:49:24.937 21286 24526 E Unity   : NullReferenceException: Object reference not set to an instance of an object.
09-15 09:49:24.937 21286 24526 E Unity   :   at FMODUnity.RuntimeManager.Initialize () [0x00000] in <00000000000000000000000000000000>:0
09-15 09:49:24.937 21286 24526 E Unity   :   at FMODUnity.RuntimeManager.get_Instance () [0x00000] in <00000000000000000000000000000000>:0
09-15 09:49:24.937 21286 24526 E Unity   :   at FMODUnity.RuntimeManager.LoadBank (System.String bankName, System.Boolean loadSamples) [0x00000] in <00000000000000000000000000000000>:0
09-15 09:49:24.937 21286 24526 E Unity   :   at Audio.FMODSound.HandleLoadBank (System.String bank) [0x00000] in <00000000000000000000000000000000>:0
09-15 09:49:24.937 21286 24526 E Unity   :   at Audio.FMODSound.OnEnable () [0x00000] in <00000000000000000000000000000000>:0
09-15 09:49:24.937 21286 24526 E Unity   : Rethrow as SystemNotInitializedException: [FMOD] Initialization failed
09-15 09:49:24.937 21286 24526 E Unity   :   at FMODUnity.RuntimeManager.get_Instance () [0x00000] in <00000000000000000000000000000000>:0
09-15 09:49:24.937 21286 24526 E Unity   :   at FMODUnity.RuntimeManager.LoadBank (System.String bankName, System.Boolean loadSamples) [0x00000] in <00000000000000000000000000000000>:0
09-15 09:49:24.937 21286 24526 E Unity   :   at Audio.FMODSound.HandleLoadBank (System.String bank) [0x00000] in <00000000000000000000000000000000>:0
09-15 09:49:24.967 18068 18253 E libmtp  : [mtp_simple_source_thread : 0224] -->ioctl failed status_ioctl:-1
09-15 09:49:24.971  1220  8706 E SensorService: BigData:Pakage) 1 already enabled.
09-15 09:49:25.040 21286 24526 E Unity   : NullReferenceException: Object reference not set to an instance of an object.
09-15 09:49:25.040 21286 24526 E Unity   :   at FMODUnity.RuntimeManager.Start () [0x00000] in <00000000000000000000000000000000>:0
09-15 09:49:25.040 21286 24526 E Unity   :
09-15 09:49:25.090 21286 24526 E Unity   : RemoteProviderException : TextDataProvider : unable to load from url : jar:file:///data/app/~~QumWip5RfPJgpYhBIpHqdg==/studio.shortsleeve.voodoodetective-uNiX379xY5zfl7cA9FKG8w==/base.apk!/assets/aa/settings.json
09-15 09:49:25.090 21286 24526 E Unity   : UnityWebRequest result : ProtocolError : HTTP/1.1 404 Not Found
09-15 09:49:25.090 21286 24526 E Unity   : ResponseCode : 404, Method : GET
09-15 09:49:25.090 21286 24526 E Unity   : url : jar:file:///data/app/~~QumWip5RfPJgpYhBIpHqdg==/studio.shortsleeve.voodoodetective-uNiX379xY5zfl7cA9FKG8w==/base.apk!/assets/aa/settings.json
09-15 09:49:25.090 21286 24526 E Unity   :
09-15 09:49:25.090 21286 24526 E Unity   : System.Action`2:Invoke(T1, T2)
09-15 09:49:25.090 21286 24526 E Unity   : UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1:set_OperationException(Exception)
09-15 09:49:25.090 21286 24526 E Unity   : UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1:Complete(TObject, Boolean, Exception, Boolean)
09-15 09:49:25.090 21286 24526 E Unity   : UnityEngine.ResourceManagement.ResourceProviders.InternalOp:CompleteOperation(String, Exception)
09-15 09:49:25.090 21286 24526 E Unity   : UnityEngine.ResourceManagement.ResourceProviders.InternalOp:RequestOperation_completed(AsyncOperation)
09-15 09:49:25.090 21286 24526 E Unity   : System.Action`1:Invoke(T)
09-15 09:49:25.090 21286 24526 E Unity   : UnityEngine.AsyncOperation:InvokeCompletionEvent()
09-15 09:49:25.090 21286 24526 E Unity   :
09-15 09:49:25.091 21286 24526 E Unity   : RuntimeData is null.  Please ensure you have built the correct Player Content.
09-15 09:49:25.091 21286 24526 E Unity   : UnityEngine.ResourceManagement.AsyncOperations.InitalizationObjectsOperation:Execute()
09-15 09:49:25.091 21286 24526 E Unity   : UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1:InvokeExecute()
09-15 09:49:25.091 21286 24526 E Unity   : System.Action`1:Invoke(T)
09-15 09:49:25.091 21286 24526 E Unity   : UnityEngine.ResourceManagement.AsyncOperations.<>c__DisplayClass57_0:<add_CompletedTypeless>b__0(AsyncOperationHandle`1)
09-15 09:49:25.091 21286 24526 E Unity   : System.Action`1:Invoke(T)
09-15 09:49:25.091 21286 24526 E Unity   : DelegateList`1:Invoke(T)
09-15 09:49:25.091 21286 24526 E Unity   : UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1:InvokeCompletionEvent()
09-15 09:49:25.091 21286 24526 E Unity   : UnityEngine.ResourceManagement.ResourceManager:ExecuteDeferredCallbacks()
09-15 09:49:25.091 21286 24526 E Unity   : UnityEngine.ResourceManagement.ResourceManager:Update(Single)
09-15 09:49:25.091 21286 24526 E Unity   : System.Action`1:Invoke(T)
09-15 09:49:25.091 21286 24526 E Unity   :
09-15 09:49:25.092 21286 24526 E Unity   : OperationException : Addressables - Unable to load runtime data at location UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1[[UnityEngine.AddressableAssets.Initialization.ResourceManagerRuntimeData, Unity.Addressables, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]].
09-15 09:49:25.092 21286 24526 E Unity   : System.Action`2:Invoke(T1, T2)
09-15 09:49:25.092 21286 24526 E Unity   : UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1:set_OperationException(Exception)
09-15 09:49:25.092 21286 24526 E Unity   : UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1:Complete(TObject, Boolean, Exception, Boolean)
09-15 09:49:25.092 21286 24526 E Unity   : UnityEngine.AddressableAssets.Initialization.InitializationOperation:Execute()
09-15 09:49:25.092 21286 24526 E Unity   : UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1:InvokeExecute()
09-15 09:49:25.092 21286 24526 E Unity   : System.Action`1:Invoke(T)
09-15 09:49:25.092 21286 24526 E Unity   : UnityEngine.ResourceManagement.AsyncOperations.<>c__DisplayClass57_0:<add_CompletedTypeless>b__0(AsyncOperationHandle`1)
09-15 09:49:25.092 21286 24526 E Unity   : System.Action`1:Invoke(T)
09-15 09:49:25.092 21286 24526 E Unity   : DelegateList`1:Invoke(T)
09-15 09:49:25.092 21286 24526 E Unity   : UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1:InvokeCompletionEvent()
09-15 09:49:25.092 21286 24526 E Unity   : UnityEngine.ResourceManag

Is there an additional step to making FMOD work with the split binary option? I saw other posts on the forum that suggested it should work out of the box in 2.0+, but that doesn’t seem to be the case.

Looks like the installation procedure is correct. Are you loading your banks asynchronously in that preload screen you mentioned in the other thread, or are you loading banks in the FMOD Settings / FMOD Studio Bank Loader?
One of the requirements for using obbs is that you stall the scene activation while you load banks asynchronously. We have an async loading example on how to do this if you haven’t seen it already.

Hey Jeff, thanks for taking a look!

Yep! I’m stalling the preload scene (and all other scenes) until the banks are loaded. I think the error is actually being thrown when LoadBank is called though. I’m not using FMOD settings to load banks.

It seems like something is failing in Initialize(). I can’t tell what line number from these stack traces.

EDIT:
Using many Debug.Log()'s, I tracked the problem down to Settings.cs:

        private void PopulatePlatformsFromAsset()
            ...
            Platform[] assetPlatforms = Resources.LoadAll<Platform>(SettingsAssetName);

assetPlatforms is empty when we build using the Split Binary option. So I guess the “FMODStudioSettings” resource can’t be loaded.

Any ideas?

I’ve reproduced this error using the adb push method / manually dragging the obb into the directory.
I have found that using Unity’s Build And Run method allows obbs to load correctly, I recommend testing with that while we look into a solution.

Hey Jeff, sorry I should have mentioned I’m also getting this error when I use the Build And Run method. I can’t seem to Load.Resources() so FMODStudioSettings doesn’t load causing FMOD not to initialize correctly.

I don’t have this issue unless I chose split binary.

Just bumping this

I noticed that the name of the obb file on my device is different to that of the packaged OBB when I “Build and Run” successfully. In my case, the OBB file is being built out of Unity as “MyProject.obb”, but when flashed to the device it is named “main.1.com.company.project.obb”.
I have found that renaming the built OBB to be my package name as defined in the Player Settings, preceded by “main.<Bundle_Version_Code>.”, has allowed me to manually adb push to my device and run succesfully.
Can you please try renaming your obb to the format of “main.<Bundle_Version_Code>.<Pakage_Name>.obb” and let me know if this workaround resolves the issue in your case also?

Ah yes, that’s also something I’ve tried with the same results. I believe the procedure you just described is essentially what “Build & Run” does for you, and I’ve done both “Build & Run” and tried to install in manually the way you suggested. Neither worked for me. It’s still failing to load anything from the streaming assets folder/resources/etc. It won’t load anything from the OBB.

I’ve unzipped the OBB and the APK and all the FMOD banks are in the OBB, they just won’t load. Nothing in the OBB is loading.

Right, looking again at your original post I see it has the appropriate name format already.
Perhaps you could try accessing the obb manually and seeing if you can load the banks from memory instead of using the runtime manager. This will at least narrow down whether the issue is with the FMOD Integration or with the placement/naming of the obb file.
Something like the following in your preload scene should tell us if the obb file is accessible or if the FMOD Integration is loading it incorrectly:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.Networking;

public class AsyncBankLoader : MonoBehaviour
{
    [FMODUnity.BankRef]
    public List<string> Banks;

    public string Scene = null;

    public void OnEnable()
    {
        StartCoroutine(LoadGameAsync());
    }

    void LoadFromObb(string bank)
    {
        var targetPath = Application.streamingAssetsPath + "/" + bank + ".bank";
        Debug.Log("[dbg] " + targetPath);

        using (var request = UnityWebRequest.Get(targetPath))
        {
            request.timeout = 2;
            request.SendWebRequest();

            while (!request.isDone) ;

            if (request.result == UnityWebRequest.Result.ConnectionError || request.result == UnityWebRequest.Result.ProtocolError)
            {
                Debug.LogError("[dbg] Failed to extract file from Obb");
                Debug.LogError("[dbg] " + request.error);
                return;
            }
            else
            {
                Debug.Log("[dbg] Succesfully found file");

                FMOD.Studio.Bank b;
                FMOD.RESULT r = FMODUnity.RuntimeManager.StudioSystem.loadBankMemory(request.downloadHandler.data, FMOD.Studio.LOAD_BANK_FLAGS.NORMAL, out b);
                if (r != FMOD.RESULT.OK)
                {
                    Debug.LogError("[dbg] " + r.ToString());
                }
            }
        }
    }

    IEnumerator LoadGameAsync()
    {
        AsyncOperation async = SceneManager.LoadSceneAsync(Scene);
        async.allowSceneActivation = false;

        foreach(var bank in Banks)
        {
            LoadFromObb(bank);
            //FMODUnity.RuntimeManager.LoadBank(bank, false);
        }

        while (FMODUnity.RuntimeManager.AnyBankLoading())
        {
            yield return null;
        }

        async.allowSceneActivation = true;

        while (!async.isDone)
        {
            yield return null;
        }
    }
}

Thanks so much for the detailed instructions and code sample!

So I tried this all out, and what I’ve found is that both:

Application.dataPath
Application.streamingAssetsPath

Are pointing to the APK and not the OBB. Since the streaming assets are actually in the OBB, it’s not loading anything. My understanding had been that when you choose “Split Binary” both dataPath and streamingAssetsPath would update to reflect the new location of those resources, but that doesn’t seem to have happened. So FMOD fails, Addressables fail, and really anything that uses those two variables fail.

If those aren’t supposed to update, then I guess that really is a problem with the FMOD integration. Otherwise, is this a Unity bug?

Also, I’m testing on a Galaxy S21 Ultra. Not sure if that makes a difference.

Hmm, Application.streamingAssets is pointing to the obb on my deivce. Perhaps you can try hard coding in the path to your obb in that loading script and see if that works?

var targetPath = "jar:file:///storage/emulated/0/Android/obb/<Package_Name>/main.<Bundle_Version_Code>.<Package_Name>.obb!/assets/" + bank + ".bank";

If that works, then the problem appears to be with Unity updating the streamingAssets path. If it doesn’t work, then the only thing I can think of would be that the obb is in a bad path or the name format isn’t matching.

I did more digging (complaining) and it turns out this is a bug in Unity for specific devices (in this case, Galaxy S21*).

Thanks for looking into this and sorry for have taken up your time.

No need to apologise, that’s what we’re here for! Thank you for sharing your findings, I’m sure this will be helpful for someone in the future.