Android NDK: UnsatisfiedLinkError when calling and using Proguard


I’m getting an UnsatisfiedLinkError exception when calling System.loadLibrary("fmod"); and using Proguard. It works fine without Proguard on.

In both cases, the exists in the lib/arm directory of the APK.

I’m using Android Studio with gradle. I activate Proguard with the minifyEnabled property set to true.

Do you guys have any idea of what’s going on?


The code in

static {

The log:

E/AndroidRuntime: FATAL EXCEPTION: main
E/AndroidRuntime: Process: com.<snip>, PID: 20003
E/AndroidRuntime: java.lang.UnsatisfiedLinkError: JNI_ERR returned from JNI_OnLoad in "/data/app/com.<snip>/lib/arm/"
E/AndroidRuntime:     at java.lang.Runtime.loadLibrary(
E/AndroidRuntime:     at java.lang.System.loadLibrary(
E/AndroidRuntime:     at com.<snip>.<clinit>`

FMOD native code will call out to the fmod.jar, we verify this is possible in JNI_OnLoad. When you obfuscate the fmod.jar there is no way for the native code to find the necessary methods so it returns a JNI_ERR.

I think you just need to exclude the fmod.jar from ProGuard, a quick Google reveals this stack overflow page that discusses how to do it.

1 Like

Thanks Mathew! I had to change my FMOD proguard configuration:
from -keepclassmembers class org.fmod.** { *; }
to -keep class org.fmod.** { *; }

1 Like