Loading assets from Android APK Expansion?

I’ve been searching for a clear answer on this scenario with Android development and FMOD Studio.

My gamedata is greater than 50MB so does not all fit into a single APK. The biggest culprit is audio - we have approximately 150MB of music and sound effects.

If I use an expansion APK, will the Asset Manager (e.g. file://android_asset/sfx.wav) and FMOD pick up the asset from the expansion APK file or must I take a different approach? If I need a different approach, what is best thing to do?

To be clear about what our asset manager integration does, when you tell FMOD to open “file:///android_asset/sfx.wav” we pass “sfx.wav” to AAssetManager_open. From some quick reading of the expansion APK docs, it doesn’t appear that the Google APIs merge these expansion files into the asset manager system, so FMOD won’t be able to load them.

The docs talk about exporting the expansion file as any format you like, which could include .zip for which they have an API to read. You could override FMOD file callbacks to integrate with this API to get access to the expansion files. Alternatively you could ship (or unpack) the audio files to your externalFilesDir then pass that path to FMOD.

1 Like

Thanks, that’s helpful to have confirmed.

Has anything changed in the past 2 years regarding this or have there been any successful cases or examples of people implementing FMOD filesystem callbacks for reading directly from expansion files?

Taking a look at the code Google provides for reading from them, you can get direct AssetFileDescriptors to files inside the zip which seems fairly similar to the usage of AssetManager in native FMOD to open assets (FMOD however does use the NDK AssetManager which is at least native unlike the zip APIs)

I want to get this working but it is way over my head in terms of implementation and I have no clue how to begin to integrate FMOD setFileSystem callbacks yet alone integrate it with the Java descriptors via JNI…

Unpacking audio files just doesn’t seem like a good option when Google strongly states you should not remove expansion files (this would then result in more than doubling app storage usage if you need random access to a lot of files)

Hi Anton, nothing’s changed on our side. If you having any specific implementation questions feel free to post them here.

Cheers