Bundled resources on Android

I am not able to use fmod on Android since the bank files cannot be found.

I am strictly following the example code from https://github.com/dapetcu21/defold-fmod in order to read the bank files from bundled resource. The same example code works fine on Mac and Windows (I cannot test on iOS). Moreover I do remember I have used fmod on Android in my previous game with no issue at all (it was end of 2021).

The bank files are in /bundled_resources/android/assets/banks and if I unzip the apk I see that they are indeed in the subfolder assets/banks in the apk. As suggested by @dapetcu21 I try to load them with the absolute path

file:///android_asset/banks/

but fmod fails to load them and also io.open returns nil with the file.

As a side note, I see that sys.get_application_path() returns “/data/user/0/com.example.todo” on Android and this looks somehow strange to me… However, I am not using this path on Android but the absolute path reported above as suggested by dapetcu21. On Mac and Windows I use sys.get_application_path() to build the absolute path and filenames and it works fine.

Finally, I have read the topics Bundle Resources Android path (SOLVED) and Where are common bundle resources supposed to be put in Android? by @Pkeod.

Any help is greatly appreciated since I am completely lost with this…

THANKS!

Ciao!

I think this is what you need to do:

# FOLDER STRUCTURE

+ /.
|
+--+ /custom
|  |
|  +--+ /common
|     |
|     +--+ /audio
|        |
|        +--+ /banks
|           |
|           +-- /main.bank
|           +-- /foo.bank
|
+-- /game.project

So you have your banks in ./custom/common/audio/banks/* and in game.project you set the Custom Resources option to /custom/:

[project]
title = mygame
custom_resources = /custom/

Note that the /common part of the path is important since it means that the files and folders in /common will be included on all platforms. You can also have platform specific folders such as /custom/armv7-android (32-bit Android) and /custom/ios (iOS regardless of architecture).

In your game you load the banks like this:

fmod.studio.system:load_bank_memory(resource.load("/custom/common/audio/banks/main.bank"), fmod.STUDIO_LOAD_BANK_NORMAL)

Oh, I see now that you want to use Bundle Resources! Ok, what I’d start by checking is if the files end up in the apk. Unzip it and confirm that the banks are there. Please also share the path to where the banks are located inside the apk.

The formatting of the paths is a bit specific when it comes to custom and bundle resources. Might be worth checking:

Thank @britzl !

Yes, I need bundled resources since otherwise fmod will not stream the background music (as explained by @dapetcu21, see: https://github.com/dapetcu21/defold-fmod ).

Yes, as I already said in my first post, I have checked that the banks are indeed in the apk, and they are in the right folders: if I unzip the apk I see the banks in game_name/assets/banks (game _name is the name of the game :slight_smile: )

In my project I have

+ game_name
 |
 +--+ bundled_resources
    |
    +--+ android
    |  |
    |  +--+ assets
    |      |
    |      +--+ banks
    |          |
    |          + -- main.bank
    |          +-- foo.bank
    |
    +--+ osx
    ...

In game.project Bundle Resources is set to “/bundled_resources/”. Please note that I am able to load the banks on Mac and Windows.

Thanks again.

Ciao, Rocco.

@niclas_aberg_winkel Thanks! I have checked this. It doesn’t seem relate to my issue unfortunately…

Ciao, Rocco.

1 Like

The great @britzl fixed this!

It was just a silly filename error: in the code I wrote an “i” instead of “I” in the filename of the fmod banks. So, I know, this makes me look completely stupid… and probably that is true.

BUT, but: what really puzzled me is that the game worked fine if launched from the editor! In the editor the fmod bank files are loaded EVEN IF their filenames are wrong…

So there is a little mystery here!

Ciao, Rocco.

1 Like

On some OS’es, filenames are case sensitive (e.g. *nix based ones like linux, android, macOS etc), and some aren’t (like Windows).

1 Like

I am using a mac

I think I have an idea why there is this problem. A previous version of the same resource had as name the name of the actual resource with “i” instead of “I”. I think this puzzled the editor.

I hope what I wrote is somehow clear…

Thanks Mathias.

I have access to the project and helped debug the issue. I think maybe resource.load() isn’t case sensitive, but I need to verify this.

1 Like