Android GetStringUTFChars中dvmDecodeIndirectRef中的DVMAPort
我用jni开发了一个android应用程序。 我在GetStringUTFChars的dvmDecodeIndirectRef中得到了一个DVMAPort。 我只做过一次流产 为什么会这样? 如何修复它 如果有人知道这一点,请教我Android GetStringUTFChars中dvmDecodeIndirectRef中的DVMAPort,android,java-native-interface,abort,Android,Java Native Interface,Abort,我用jni开发了一个android应用程序。 我在GetStringUTFChars的dvmDecodeIndirectRef中得到了一个DVMAPort。 我只做过一次流产 为什么会这样? 如何修复它 如果有人知道这一点,请教我 对不起,信息不充分 这是我的密码 std::string toStdStr(JNIEnv* env, jstring jstr) { const char* chars = env->GetStringUTFChars(jstr, 0); //<-d
对不起,信息不充分 这是我的密码
std::string toStdStr(JNIEnv* env, jstring jstr)
{
const char* chars = env->GetStringUTFChars(jstr, 0); //<-dvmAbort
std::string stdstr;
if( NULL==chars ) {
stdstr = "";
}else{
stdstr = std::string(chars );
env->ReleaseStringUTFChars(jstr, chars );
}
return stdstr;
}
std::string-toStdStr(JNIEnv*env,jstring-jstr)
{
const char*chars=env->GetStringUTFChars(jstr,0);//ReleaseStringUTFChars(jstr,chars);
}
返回stdstr;
}
下面是nkd堆栈崩溃转储
我用xxxxxxxx重写了私人信息
********** Crash dump: **********
Build fingerprint: 'xxxxxxxx'
pid: xxxxxxxx, tid: xxxxxxxx, name: Thread-78 >>> xxxxxxxx <<<
signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
Stack frame #00 pc xxxxxxxx /system/lib/libc.so (tgkill+12)
Stack frame #01 pc xxxxxxxx /system/lib/libc.so (pthread_kill+48)
Stack frame #02 pc xxxxxxxx /system/lib/libc.so (raise+10)
Stack frame #03 pc xxxxxxxx /system/lib/libc.so
Stack frame #04 pc xxxxxxxx /system/lib/libc.so (abort+4)
Stack frame #05 pc xxxxxxxx /system/lib/libdvm.so (dvmAbort+78)
Stack frame #06 pc xxxxxxxx /system/lib/libdvm.so (dvmDecodeIndirectRef(Thread*, _jobject*)+146)
Stack frame #07 pc xxxxxxxx /system/lib/libdvm.so
Stack frame #08 pc xxxxxxxx /system/vendor/lib/libxxxxxxxx.so toStdStr(_JNIEnv*, _jstring*)+56): Routine _JNIEnv::GetStringUTFChars(_jstring*, unsigned char*) at /home/softdev/opt/android-ndk-r9d/platforms/android-19/arch-arm/usr/include/jni.h:879
...
**********崩溃转储:**********
生成指纹:“xxxxxxxx”
pid:xxxxxxxx,tid:xxxxxxxx,名称:Thread-78>>>xxxxxxxx这意味着jstr
在传递到toStdStr
时无效。在调用toStdStr之前,请尝试env->CreateGlobalRef(jstr)
。别忘了发布全局引用 请包括导致错误的相关代码。