JniHelper 在android5.0下编译成功但是运行错误 求大神指导

萧萧寒水
Tue, 25 Aug 2015 06:28:21 +0000

c++代码

JniMethodInfo minfo;
if(JniHelper::getStaticMethodInfo(minfo,“org/cocos2dx/lib/Cocos2dxActivity”,“GetUID”,"()Ljava/lang/String;"))
{
jstring strRet = (jstring)minfo.env->CallObjectMethod(minfo.classID, minfo.methodID);

string str = minfo.env->GetStringUTFChars(strRet,false);

minfo.env->DeleteLocalRef(strRet);

minfo.env->DeleteLocalRef(minfo.classID);

return str;
}

java代码

public static String GetUID()
{

String s_uid=Installation.GetID(mbrowser);

String o_uid=s_uid.replace("-", “”);

System.out.println(“GetUUID:1111111”);

return o_uid;

}

在三星android4.3和联想android4.4.2上运行这段代码是没有任何问题，但是在华为EMUI3.1 android 5.0.1上运行这段代码就会报错且无输出

但是在华为上运行

c++代码

JniMethodInfo minfo;

if(JniHelper::getStaticMethodInfo(minfo,“org/cocos2dx/lib/Cocos2dxActivity”,“GetUUID”,"()I"))

{

jint __result;

__result = minfo.env->CallStaticIntMethod(minfo.classID, minfo.methodID);

minfo.env->DeleteLocalRef(minfo.classID);

}

java代码

public static int GetUUID()

{

String s_uid=Installation.GetID(mbrowser);

String o_uid=s_uid.replace("-", “”);

System.out.println(“GetUUID:1111111”);

      return  1111111;

}

却不报错，不知道有没有大神知道是什么问题

编译环境为

android 4.4.2

NDK r10d

错误信息为:art/runtime/check_jni.cc:65] JNI DETECTED ERROR IN APPLICATION: calling static method java.lang.String org.cocos2dx.lib.Cocos2dxActivity.GetUID() with CallObjectMethodV

阅读整个主题