# Null references loading banks from Unity AssetBundles in Android build

**URL:** https://qa.fmod.com/t/null-references-loading-banks-from-unity-assetbundles-in-android-build/21435
**Category:** Unity
**Tags:** android
**Created:** [April 1, 2024, 7:46pm UTC](https://qa.fmod.com/t/null-references-loading-banks-from-unity-assetbundles-in-android-build/21435 "2024-04-01T19:46:19Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![buckadmin](https://avatars.discourse-cdn.com/v4/letter/b/a5b964/32.png) [@buckadmin](https://qa.fmod.com/u/buckadmin)
#### Post date: [April 1, 2024, 7:46pm UTC](https://qa.fmod.com/t/null-references-loading-banks-from-unity-assetbundles-in-android-build/21435/1 "2024-04-01T19:46:19Z")

</div>

Hello,

We are getting null reference exceptions when calling RuntimeManager.LoadBank() on Android builds. Most curiously, the bank loading works fine if I switch to **Streaming Assets** as our **Import Type** in the FMOD settings, however, it will not work when using **Asset Bundles** , which is what we want to use for our architecture (this approach is already working on iOS, desktop, and in editor with the Android simulator)

RuntimeManager.LoadBank() is executed asynchronously within an Awaitable as follows:

```auto
                //Banks is a List<string> that defines all of our bank names
                foreach (var bank in Banks)
                {
                    Debug.Log("Load bank:" + (bank as string));
                    
                    RuntimeManager.LoadBank(bank, true);
                }

                Debug.Log("Begin waiting.");

                // Keep yielding the until all the bank loading is done
                // (for platforms with asynchronous bank loading)
                while (!FMODUnity.RuntimeManager.HaveAllBanksLoaded)
                {
                    //Debug.Log("Wait.");
                    await Awaitable.NextFrameAsync();
                }

```

**Unity version:** 2023.2.5f1  
**FMOD version:** 2.02.19  
We have **Split Application Binary** set to true in our **Project Settings**

Here is one copy of the error from trying to load one of the banks:

```auto
2024/04/01 15:19:00.058 15941 15962 Error Unity NullReferenceException: Object reference not set to an instance of an object.
2024/04/01 15:19:00.058 15941 15962 Error Unity at FMOD.Studio.System.loadBankMemory (System.Byte[] buffer, FMOD.Studio.LOAD_BANK_FLAGS flags, FMOD.Studio.Bank& bank) [0x00000] in <00000000000000000000000000000000>:0 
2024/04/01 15:19:00.058 15941 15962 Error Unity at FMODUnity.RuntimeManager+<loadFromWeb>d__57.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 
2024/04/01 15:19:00.058 15941 15962 Error Unity at UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) [0x00000] in <0000000000
 (302.6 KB)
0000000000000000000000>:0 

```

Here is a text file of the Android Log cat from trying to run the build with **Enable API Error Logging** on and **Logging Level** set to “Log”. This created a lot of new errors that I wasn’t receiving before enabling logging. I believe they are only happening because our general API stack is falling apart from failing to load the banks (which is our core problem).

[fmodandroidlog.txt](https://qa.fmod.com/uploads/short-url/18aCTPiumHuuX0yaif1lOL9x2VC.txt)

Thank you!

---

<div class="post-metadata">

### Author: ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)
#### Post date: [April 5, 2024, 3:16am UTC](https://qa.fmod.com/t/null-references-loading-banks-from-unity-assetbundles-in-android-build/21435/2 "2024-04-05T03:16:21Z")

</div>

If you are using **AssetBundles** then you will need to handle loading the asset, using the `AssetBundle` api, before loading the bank using [`LoadBank(TextAsset asset)`](https://www.fmod.com/docs/2.03/unity/api-runtimemanager.html#loadbank) instead of the string version of `LoadBank`.

See our documentation on [Using AssetBundles](https://www.fmod.com/docs/2.03/unity/user-guide.html#using-assetbundles).
