Fmod android integration

I’ve been using FMOD for years in PC builds but now working on an Android Studio application. The project is Native Activity primarily c++ and I’m using the latest Android build release. I’ve followed the set up for the 3D example (using cmake) and have another library working fine using he exact same configuration. I’m targeting arm64-v8a. Unfortunately FMOD will not initialize and I get the following errors:

I/fmod: FMOD_OS_Init : Detected CPU family: 4, features: 0x7F, cores: 8.
E/fmod: FMOD_JNI_GetEnv : JNI_OnLoad has not run, should have occurred during System.LoadLibrary.

I’ve been tracing through other similar posts here such as


but to no avail. Any and all help would be appreciated.

It looks like you’re missing the Java component of the FMOD setup.
In our Android specific docs, there is a section on initializing Java that should help.

I’ve included the init(), close() and load library static functions as outlined in this reference but to no avail. The build gradle also references the jar file as per the example.

I’ve looked at the documentation as well as the second forum post I referenced about attaching the current thread as I am initializing from within a native activity but so far no luck. Is there an example of this anywhere I could reference to make sure I’m calling the attach thread correctly?

Hey CogSimGuy,

I’m not quite sure how you are initialising fmod. It’s worth checking any differences between your implementation and MainActivity.java in the examples.

If that doesn’t help, if you could provide your initialisation code we should be able to help further.

Make sure you are calling System.loadLibrary("fmod") (or whatever your wrapper is) in Java/Kotlin before you call FMOD.init(context).

Josh,

I was finally able to sort it out over the weekend. It was a combination of things…Android Studio + gradle + CMake are an ugly combination of subtleties!

Scott

Android.mk and Application.mk improves matters somewhat, but it’s definitely not particularly clean! Glad you got it sorted.