带有JNI代码的Android致命信号6(SIGABRT)

时间:2018-01-21 20:03:33

标签: android c++ java-native-interface

我正在使用C ++和SDL2为Android编写游戏。在Android 4.0.4中一切都很好。但是在Android 5.1中,当执行env-> CallStaticVoidMethod时,我得到一个致命信号6(SIGABRT),tid 12201(SDLThread)中的代码-6。我找不到让它发挥作用的方法。

JNIEXPORT jint JNICALL Java_com_digit_appactivity_init(JNIEnv* env, jobject obj)
{
        // Obtain the Java class.
        env->GetJavaVM(&s_vm);
        LOGD("GetJavaVM Executed");

        libClass = env->FindClass("com/digit/appactivity");
        LOGD("FindClass Executed");


        // C++ => Java methods.
        javanamefunctionMethod = env->GetStaticMethodID(libClass, "javanamefunction", "(I)V");
        LOGD("GetStaticMethodID Executed");

        return 0;
}


void android_paymoney(jint money)
{
        JavaVM* vm = ME_JavaVM();
        JNIEnv* env = 0;

        int vm_attached = vm->GetEnv((void**)&env, JNI_VERSION_1_6);
        LOGD("GetEnv Executed");

        env->CallStaticVoidMethod(libClass,  javanamefunctionMethod, money); //here is the error
        LOGD("CallStaticVoidMethod Executed"); // this is not executed, app crashes
}

0 个答案:

没有答案