Proguard & JNI in Android Studio


#1

Hi,
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 proguard-rules.pro to avoid this?

Thanks


#2

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

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


#3

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