Bad JNI version passed to AttachCurrentThread:

出现这个错误时,发现JNI层有error打印,原因是 java version没有提供

   if (event  == ASSOCIATE_JVM) {
        JavaVMAttachArgs args;
        char name[] = "XX Service Callback Thread";
        //args.version = JNI_VERSION_1_6;
        args.name = name;
        args.group = NULL;
        vm->AttachCurrentThread(&callbackEnv, &args);
        ALOGV("Callback thread attached: %p", callbackEnv);
    } 


修改成下面的就OK了 

   if (event  == ASSOCIATE_JVM) {
        JavaVMAttachArgs args;
        char name[] = "XX Service Callback Thread";
        args.version = JNI_VERSION_1_6;
        args.name = name;
        args.group = NULL;
        vm->AttachCurrentThread(&callbackEnv, &args);
        ALOGV("Callback thread attached: %p", callbackEnv);
    } 



你可能感兴趣的:(java,android)