无法使用jni在android lollipop中使用c ++进行JNI调用

pur*_*ima 5 c++ java-native-interface android android-5.0-lollipop

我正在制作一个图书馆应用程序,使用谷歌破解板检测Android中的本机崩溃.每当我的主应用程序发生本机崩溃时,breakpad都会调用以下回调.从这个回调中,我需要使用JNI在java类中调用静态void方法.

bool breakpad_callback(const google_breakpad::MinidumpDescriptor& descriptor, void* context, bool succeeded) {

JNIEnv* env = NULL;

if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK)
{
    if(isDebug)
        LOGI("Failed to get the environment");
    return false;
}

if(isDebug)
    LOGI("attaching thread ...");
vm->AttachCurrentThread(&env, NULL);

if(isDebug)
    LOGI("handle exception");

 ExceptionHandlerClass = (jclass)env->NewGlobalRef(env->FindClass("com/abc/Myclass"));
        if (ExceptionHandlerClass == NULL)
            LOGE("Could not find java class");

 ExceptionHandlerMethod = env->GetStaticMethodID(ExceptionHandlerClass, "handleException", "()V");
        if (ExceptionHandlerMethod == NULL)
            LOGE("Could not bind exception handler method");

// handle exception
env->CallStaticVoidMethod(ExceptionHandlerClass, ExceptionHandlerMethod);

if(env->ExceptionCheck()) {
    LOGI("got exception");
    env->ExceptionDescribe();       
}


if(isDebug)
    LOGI("exception handled");
}
Run Code Online (Sandbox Code Playgroud)

这是我的java方法:

package com.abc;
public class Myclass {
  public static void handleException() {
     System.out.println("inside handle exception");
  }
}
Run Code Online (Sandbox Code Playgroud)

这曾经在Android 5.0之前正常工作.但是在Lollipop中,我无法调用我的java方法,因为我无法在Logcat控制台上看到"内部句柄异常"日志.

以下是我在logcat上看到的日志消息:

12-01 13:57:46.617: I/AACRNative(1617): attaching thread ...
12-01 13:57:46.617: I/AACRNative(1617): handle exception
12-01 13:57:46.619: I/AACRNative(1617): got exception
12-01 13:57:46.620: W/art(1617): JNI WARNING: java.lang.StackOverflowError thrown while calling printStackTrace
12-01 13:57:46.620: I/AACRNative(1617): exception handled
Run Code Online (Sandbox Code Playgroud)

有人可以帮我这个吗?

ben*_*daf 0

这是一个已知问题,它提到了一些解决方法,但尚未修复。ART 使用备用堆栈进行信号处理,这会导致问题。