Search code examples
javaandroidandroid-ndknativendk-build

Android NDK release Build method not found


I have a little problem with an native Android Libary. I am calling a Method from native Code like this:

        clazz = env->FindClass("<package>/NativeInterface");;
        midlog = env->GetStaticMethodID(clazz, "callStr", "(Ljava/lang/String;)V");
        jstring jstr = env->NewStringUTF(s.c_str());
        env->CallStaticVoidMethod(clazz, midlog, jstr);

When I Build my App in Debug mode, I have no problems with this. But when i Build in release mode, I get an error :

Throwing new exception 'no static method "L<package>/NativeInterface;.callStr(Ljava/lang/String;)V

Could it be that Android Studio is obforscating the java code and my native libary is not able to find the methode any longer? What is my Problem here?


Solution

  • Obfuscation per se is not a problem, but ProGuard can remove "unused" methods. You can use -keep option or plant a fictional call to prevent striping of callStr()