1
我是新的Android JNI。我將Java文件中的JAVA對象發送給下面給出的C代碼。其實我認爲我無法將jObject轉換爲字符,因此當我編譯此代碼時,我得到以下錯誤:Android的JNI錯誤:警告:初始化從指針沒有投的指針整數
警告:初始化會使指針中的整數無法投射
我的C文件:
typedef struct {
unsigned char reg_chal[32];
unsigned char aid[32];
} reg_info_t;
JNIEXPORT jint JNICALL Java_com_marakana_NativeLib_reg(JNIEnv *env,jclass obj,jobject info ,jchar details,jchar reg_code)
{
reg_info_t regInfo;
jclass clazz;
jfieldID fid;
jmethodID mid;
jint status =0;
LOGD("NDK:LC: [%s]", "JNI Function call started");
LOGD("NDK:LC: [%s]", details);
LOGD("NDK:LC: [%c]", reg_code);
//GetInfo(entryInfo); // fills in the entryInfo
clazz = (*env)->GetObjectClass(env, info);
if (0 == clazz)
{
printf("GetObjectClass returned 0\n");
return(-1);
}
jchar reg_chal = (*env)->NewStringUTF(env,regInfo.reg_chal);
fid = (*env)->GetFieldID(env,clazz,"reg_chal","Ljava/lang/String;");
(*env)->SetObjectField(env,info,fid,reg_chal);
LOGD("NDK:LC: [%c]", reg_chal);
jchar aid = (*env)->NewStringUTF(env,regInfo.aid);
fid = (*env)->GetFieldID(env,clazz,"aid ","Ljava/lang/String;");
(*env)->SetCharField(env,info,fid,aid);
LOGD("NDK:LC: [%c]", aid);
//reg_step_1(info , details, reg_code);
//status = reg_step_1(info , details, reg_code);
return status;
}
請幫我如何解決轉換的這個錯誤?
@ Struart Cook:謝謝你的幫忙。它現在正在構建這個lib。但是現在我得到了一種新的錯誤:I/DEBUG(31):*** *** *** *** *** *** *** *** *** * ** *** *** *** *** *** I/DEBUG(31):構建指紋:'generic/sdk/generic /:2.2/FRF91/43546:eng/test-keys' (31):pid:692,tid:692 >>> com.marakana <<< I/DEBUG(31):信號11(SIGSEGV),故障地址00000064任何想法如何解決信號11錯誤在ndk?感謝您的幫助 –