Proguard & JNI in Android Studio


We are in the process of releasing our first Muse application for Android using Android Studio. While enabling Proguard to optimize the code, we encountered this problem with the JNI Muse library.

JNI DETECTED ERROR IN APPLICATION: JNI NewGlobalRef called with pending exception 'java.lang.ClassNotFoundException' thrown
    in call to NewGlobalRef
    from java.lang.String java.lang.Runtime.nativeLoad(java.lang.String, java.lang.ClassLoader, java.lang.String)

Disabling Proguard fix the error, so it is related to classes being discarded. What configurations are you using in to avoid this?



Oh well. Sometimes it’s only a matter of publishing the problem to finally get the solution!

Solution : -keep class com.interaxon.libmuse.* { *; }


Just an update to this. Interaxon changed the name of the libmuse package from interaxon to choosemuse.

Now, the correct solution is to include:

-keep class com.choosemuse.libmuse.* { *; }

in your .pro proguard file