Bundle Resources Android path (SOLVED)

What should a working path example look right for Android Bundle Resources?

For example, with FMOD extension I can use “./_assets/_fmod_banks/master.bank” for Windows Bundle Resources, but this does not work with Android.

For resources that should end up directly in the .apk (i.e the zip file), you should use bundle resources (example)

For Android Assets, they should be under “/res/”.
In this example “admob/res/android”

Would I expect to add res to the front of the path for it to work?

“./res/_assets/_fmod_banks/master.bank”

If you specify a “bundle_resources” path, you should point to a directory containing platform assets:
example.
In this folder, we will look for platform folders, and any files under there, will be copied (with relative paths) to the bundle (same for all platforms)

If you are talking about the “res” folder in a native extension, that folder too will have platform folders under it. And, on top of it, the Android build process dictates that actual resource files should be under yet another “res” folder. This is used for android resources (e.g. xm files, icons etc):

<extension>/res/android/res/draw/...

However, if you wish to put a binary file as-is, into the Android’s special assets folder, put it under the bundle_resources folder (e.g. “/res”:

<project>/res/android/assets/fmod_banks/master.bank

Note: If you wish to have the same asset in all platforms, you can use the platform name “common”

At the moment, we do use the common folder for bundle resources. To be clear, everything works on Windows but on Android it complains about being unable to find the file with the same path. On Windows the folder next to the exe does appear and it’s accessible. I’m still sort of confused about how it should work with Android.

So I would need to edit the android manifest for this to work?

Edit: Wait, so for Android to work we have to have a “res” folder name for the bundle resources? That might be okay but we’re only allowed to define a single folder as bundle_resources…

Edit2: That can’t be it can it? I think we’re both confused. Again bundle_resources works with Windows but I’m confused about what the path should be on Android. I tried adding res to the start of the path and it didn’t work.

I looked at the apk and it does place the files where I want them, but for whatever reason the path to load them from the FMOD native extension is not working.

It looks like this right now

apk

Are there problems here? Should they actually be in the res folder only to be accessible?

The path issue is just the dot at the start. Windows needs it but not other platforms.

But the issue I’m still trying to figure out is a little to it so I’ll update the thread with more info when I have it.

I switched the banks to a custom resource instead of a bundle resource and then used fmod.studio.system:load_bank_memory instead of fmod.studio.system:load_bank_file and then / style path with no ./ works. I’d still like to figure out how to get fmod.studio.system:load_bank_file to work on Android eventually.

I don’t think you’ll be able to get that to work easily. You would need to get the absolute path to the location of the application and then build from there. Using ‘.’ for a relative path will very likely be a different location than the root of the APK. You could use LuaFileSystem and iterate the files in ‘.’ to figure out where you’re actually at on Android.

We have a new extension where we use a videofile, and we load it as an Android asset.
In the game.project, we specify this:

[project]
bundle_resources = /res

And the file is located under:

<project>/res/common/assets/big_buck_bunny_720p_1mb.mp4

And inside the videoplayer, we get that asset as a file descriptor:

code:

String path = "big_buck_bunny_720p_1mb.mp4";
AssetFileDescriptor afd = activity.getAssets().openFd(path);
2 Likes

I’ll give a shot doing something like that in the future.

1 Like

Hey,
I’m using this room again, because I have almost the same problem.
I try to use the bundle resources on Android bundle.

What I don’t understand is how to implement the bundle reources.

1 ) Should it be implemented by unzipping the apk file?
create zip

1.1 ) If so, I get an error that says:
“The compressed file is invalid or damaged.”. How to solve this problem?

1.2 ) I tried with winrar, adding the file works, but as soon as I try to open it as .apk with BlueStacks, but it say: “installation error”.

2 ) How to implement the bundle reources other than by unzipping the apk file?

Thank you for your future response !!! :grin:

In windows, usually when you double click on a .zip file, it doesn’t actually extract the archive. Instead, it mounts it like a readable folder that you can browse.
I don’t believe you can add assets to that folder structure.

In any case, that’s not how our bundle resources work.

In the game.project, specify a folder that should be included when we create the apk for you. Inside the bundleresources folder, you may have a platform specific folder as well, to
allow for copying platform specific files.

Try it, then open the .apk (.zip) to inspect how the files are put into the archive.

What do you currently have set as the “game.bundle_resources” property?

I’ve already tried, but it says “file not found or read not allowed”.

image

In your project, do you have a folder called “android/res” (like it says in your screenshot)?

E.g. in your project, create a folder like so:

<project_folder>/bundle_resources/

In that folder, you can put other things, like your android folder

<project_folder>/bundle_resources/android/res

Then specify the bundle resource folder in game.project

game.bundle_resources = /bundle_resources

An example is the DefOS project:

Also, you posted the gif twice, where you try to copy the “banks” folder into the extracted folder.
That’s not how our “bundle_resources” work.

Ok, I understand better.
There’s just the path I don’t know how to look for it.

Mmmmhh, I still can’t do it. :expressionless:

What’s my fault ?

I rely on this to load banks :

After bundling, what’s the folder structure inside your .apk?