android art runtime check_jni.cc error on package name

前端 未结 1 371
不思量自难忘°
不思量自难忘° 2021-01-07 07:20

--EDIT-- i had too many versions of the shared lib floating around due to ambiguous build.gradle...

./src/main/jniLibs/armeabi-v7a/libaudioboo-native.so
rob         


        
相关标签:
1条回答
  • 2021-01-07 07:43

    I've had the same problem on upgrading to Android 5, and have just sorted it.

    The bug is in your native code, not in your java code. Somewhere in your native code you have a function that gets passed a FlacStreamEncoder object through jni as a jobject and you retrieve it with a line like:

        jclass streamEncoder = env->FindClass("fm.audioboo.jni.FLACStreamEncoder");

    But JNI is supposed to use "/" as a separator not ".", so this line should read:

        jclass streamEncoder = env->FindClass("fm/audioboo/jni/FLACStreamEncoder");

    instead. Previous versions of android silently ignored this problem, but now it just blows up in your face instead.

    From https://android.googlesource.com/platform/art/+/kitkat-dev/runtime/check_jni.cc

        // Checks that 'class_name' is a valid "fully-qualified" JNI class name, like "java/lang/Thread"
        // or "[Ljava/lang/Object;". A ClassLoader can actually normalize class names a couple of
        // times, so using "java.lang.Thread" instead of "java/lang/Thread" might work in some
        // circumstances, but this is incorrect
        void CheckClassName(const char* class_name) {
            if (!IsValidJniClassName(class_name)) {
                JniAbortF(function_name_,
                          "illegal class name '%s'\n"
                          " (should be of the form 'package/Class', [Lpackage/Class;' or '[[B')",
                          class_name);
                }
            }
        }
    
    0 讨论(0)
提交回复
热议问题