# Can not load bank(.bytes) In Resources Files

**URL:** <https://qa.fmod.com/t/can-not-load-bank-bytes-in-resources-files/19014>\
**Category:** Unity\
**Tags:** unity\
**Created:** [July 18, 2022, 10:50am UTC](https://qa.fmod.com/t/can-not-load-bank-bytes-in-resources-files/19014 "2022-07-18T10:50:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![shj6078](https://avatars.discourse-cdn.com/v4/letter/s/8e7dd6/32.png) [@shj6078](https://qa.fmod.com/u/shj6078)\
**Post date:** [July 18, 2022, 10:50am UTC](https://qa.fmod.com/t/can-not-load-bank-bytes-in-resources-files/19014/1 "2022-07-18T10:50:37Z")

</div>

I can not load bank in Android device. That bank file include to Resources File.

I was setting FMOD Import Type AssetBundle, because i use addreassable.  
When Importing FMOD banks in FMOD Asset Sub Folder path, And then i copyied one of them(master.assets.bytes,master.bytes, …etc) to Resource Folder.  
Why i use the banks file in Resources Folder, because i need to play some BGM sound before download ing bank files from addressable.

so, **i got a error logcat in android device (ERR\_FORMAT). see below the error**

```auto
07-18 19:21:46.570: E/Unity(17261): BankLoadException: [FMOD] Could not load bank 'Master.assets' : ERR_FORMAT : Unsupported file or audio format.
07-18 19:21:46.570: E/Unity(17261): at FMODUnity.RuntimeManager.LoadBank (UnityEngine.TextAsset asset, System.Boolean loadSamples) [0x00000] in <00000000000000000000000000000000>:0 
07-18 19:21:46.570: E/Unity(17261): at SoundSample.Start () [0x00000] in <00000000000000000000000000000000>:0 

```

please help to this prorblem.

you can check my code and setting things below the screenshots.

//this is my code

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/6/6ada8908c76cecabd542f1f26ddeaa41bcf633b1.png)

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/d/df40d654ae54739c20f4091368703874984c4417.png)

//this is my editsetting

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/8/8c39eec7cd5b3978075b54e8cc63356603996616.png)

//this is bytesfiles in FMOD Asset Sub Folder path

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/5/5a41bc90bb597f484de5d0afb043a1daaeba9c54.png)

//this is bytes files that load bank in Resources folder path

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/7/7f508df2c2e544c34b9928a78eaee6802578608c.png)

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [July 22, 2022, 3:21am UTC](https://qa.fmod.com/t/can-not-load-bank-bytes-in-resources-files/19014/2 "2022-07-22T03:21:04Z")

</div>

Hi,

Thank you for taking those screenshots, they helped a lot!

You are missing one crucial step in getting this to work. A deeper explanation of each step can be found in the Unity Docs under [Unity Integration | AssetBundles & Addressables.](https://fmod.com/docs/2.02/unity/user-guide.html#assetbundles-addressables)

First, select all your build FMOD `text assets` and assign them to a new `AssetBundle`. You can have as many differently named `AssetBundles` as you need to load in different `banks` when they are required.

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/e/e87557d3c20331003b4d69a45718a77cf2c19cc8.png)

Keep in mind the `name` you use, as it is required for the next step.

Once all your FMOD `text assets` have been assigned to an `AssetBundle`, even ones that will be loaded in later, then we need to build them using the example from the Docs:

> **BuildAssetBundles class**
>
> ```auto
> using FMODUnity;
> using UnityEditor;
> using UnityEngine;
> // This #if statement will stop the function being compiled in build as we are using Editor only function calls
> #if UNITY_EDITOR
> 
> public class BuildAssetBundles
> {
> [MenuItem("Tools/Build Asset Bundles")]
> public static void StartProcess()
> {
> BuildTarget buildTarget = BuildTarget.StandaloneWindows64;
> 
> EventManager.CopyToStreamingAssets(buildTarget);
> // The function's first parameter will be the file path where you want your AssetBundles to be built. In your case: Application.dataPath + "//Resources//Sound". However, it is a good idea to leave these in the `StreamingAsset` folder 
> BuildPipeline.BuildAssetBundles(Application.dataPath + "//Resources//Sound", BuildAssetBundleOptions.None, buildTarget);
> 
> EventManager.UpdateBankStubAssets(buildTarget);
> }
> };
> #endif
> 
> ```

This script will give us a new option on the Unity toolbar under `Tools`  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/3/3d246e7bba1c67173d9d27ef97841f864a58c097.png)

When you click this option it should build all your FMOD `text assets` into Unity `AssetBunldes` in the destination folder. The destination folder will have to exist before the function is called.

Now we will need to load those `AssetBundles` like this:

> **LoadAllBanks class**
>
> ```auto
> using System.IO;
> using UnityEngine;
> 
> public class LoadAllBanks : MonoBehaviour
> {
> void Awake()
> {
> // This will need to be the same file path as where you are building the AssetBundles too.
> var assetBundle = AssetBundle.LoadFromFile(Path.Combine(Application.dataPath + "/Resource/Sound", "banks"));
> if (assetBundle == null)
> {
> Debug.LogError("Failed to load AssetBundle!");
> return;
> }
> 
> foreach (var name in assetBundle.GetAllAssetNames())
> {
> FMODUnity.RuntimeManager.LoadBank(assetBundle.LoadAsset<TextAsset>(name));
> }
> FMODUnity.RuntimeManager.StudioSystem.getBankCount(out int count);
> 
>         
> assetBundle.Unload(false);
> }
> }
> 
> ```

Now your `banks` should hopefully be loaded. Keep in mind that not all banks need to loaded in simultaneously. However, the `Master.bytes` and the `Master.strings.bytes` will need to be loaded first.

Hope this helps!

---

<div class="post-metadata">

**Author:** ![shj6078](https://avatars.discourse-cdn.com/v4/letter/s/8e7dd6/32.png) [@shj6078](https://qa.fmod.com/u/shj6078)\
**Post date:** [July 25, 2022, 2:45am UTC](https://qa.fmod.com/t/can-not-load-bank-bytes-in-resources-files/19014/3 "2022-07-25T02:45:22Z")

</div>

Thanks to anwser.  
But you miss that i said use addressable, not use the assetBundle.  
please guide for me again that addressable

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [July 26, 2022, 4:20am UTC](https://qa.fmod.com/t/can-not-load-bank-bytes-in-resources-files/19014/4 "2022-07-26T04:20:09Z")

</div>

My apologies I missed that, to use `Addressables` follow this example:

1. We need to ensure we have defined `UNITY_ADDRESSABLES_EXIST` in the player settings. This can be found under Unity Toolbar → Edit → Project Settings → Player → Other Settings → Script Compilation. You may get some errors in the console but that is fine, they will be solved in the next step.  

2. Import the `Addressable Package` from the Unity `Asset Manager Window` under Unity Toolbar → Window → Package Manager → Unity Registry → Addressables.

> **Package Manager**
>
> ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/0/089e2932de7011d78de1ad088947382890c35759.png)

1. Assign the FMOD `Text Assets` to `Addressables`, you can do this by selecting them in your `Project Directoy` and ticking the `Addressable` tick box  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/7/74b763458d65a39db1fd502208c167dd747ce836.png)
2. The `Addressables` will want to be loaded into memory `Asyn
3. Now the `Addressables` are ready to be loaded into memory. Create a new script named `LoadAllBanks` and then copy the following example into that script. You can change the name if you like.

> **LoadAllBanks class**
>
> ```auto
> Using UnityEngine; 
> using System;
> using System.Collections.Generic;
> using UnityEngine.AddressableAssets;
> using System.Collections;
> using UnityEngine.SceneManagement;
> 	
> public class LoadAllBanks : MonoBehaviour
> {
> public List<AssetReference> Banks = new List<AssetReference>();
> public string Scene;
> 	
> private static int numberOfCompletedCallbacks;
> 	
> void Awake()
> {
> StartCoroutine(LoadBanksAsync());
> }
> 	
> private Action Callback = () =>
> {
> numberOfCompletedCallbacks++;
> };
> 	
> IEnumerator LoadBanksAsync()
> {
> 	
> Banks.ForEach(b => FMODUnity.RuntimeManager.LoadBank(b, true, Callback));
> 	
> while (numberOfCompletedCallbacks < Banks.Count)
> yield return null;
> 	
> while (FMODUnity.RuntimeManager.AnySampleDataLoading())
> yield return null;
> 	
> AsyncOperation async = SceneManager.LoadSceneAsync(Scene);
> 	
> while (!async.isDone)
> {
> yield return null;
> }
> 	
> Banks.ForEach(b => b.ReleaseAsset());
> }
> }
> 
> ```

1. In the Inspector window of an object with your script, add the `banks` you wish to load  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/0/06865e404f05de30d02f559297bca128b4d790da.png)

2. Loading Unity assets are an Asynchronous operation, further explanation can be found in [Unity | Getting started with Addressable Assets](https://docs.unity3d.com/Packages/com.unity.addressables@0.4/manual/AddressableAssetsGettingStarted.html), so we will need an empty `scene` to load the `banks` then a populated `scene` to play them in. So in your Unity `Build Settings` you will want to have something like this:  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/d/d3b59b6613735d5847b48ee3073009992548dba9.png)  
In the `EmptyScene` is our object that loads our `banks`, then we transition to the `MusicScene` where we will hear our events.

3. Make sure to start the project in the `EmptyScenetoLoadBanks`, now all the assigned `banks` should be loaded

Sorry about the confusion, I hope this helps!
