JNI ERROR wrong type
【摘要】
JNI DETECTED ERROR IN APPLICATION: attempt to set field byte com.shares.sdk.callinfo.BatteryStatus.battery_remaining with value of wrong type: L
08-04 17:11:07.529 2447-2505/c...
JNI DETECTED ERROR IN APPLICATION: attempt to set field byte com.shares.sdk.callinfo.BatteryStatus.battery_remaining with value of wrong type: L
08-04 17:11:07.529 2447-2505/com.shares.sdk.pvsdkapitest A/art: art/runtime/check_jni.cc:70] in call to SetObjectField
08-04 17:11:07.529 2447-2505/com.shares.sdk.pvsdkapitest A/art: art/runtime/check_jni.cc:70] "Thread-1130" prio=5 tid=24 Runnable
08-04 17:11:07.529 2447-2505/com.shares.sdk.pvsdkapitest A/art: art/runtime/check_jni.cc:70] | group="main" sCount=0 dsCount=0 obj=0x12ea10a0 self=0xeec75400
08-04 17:11:07.529 2447-2505/com.shares.sdk.pvsdkapitest A/art: art/runtime/check_jni.cc:70] | sysTid=2505 nice=0 cgrp=default sched=0/0 handle=0xef047000
08-04 17:11:07.529 2447-2505/com.shares.sdk.pvsdkapitest A/art: art/runtime/check_jni.cc:70] | state=R schedstat=( 10710532 5781384 279 ) utm=1 stm=0 core=3 HZ=100
08-04 17:11:07.529 2447-2505/com.shares.sdk.pvsdkapitest A/art: art/runtime/check_jni.cc:70] | stack=0xe048b000-0xe048d000 stackSize=1012KB
08-04 17:11:07.529 2447-2505/com.shares.sdk.pvsdkapitest A/art: art/runtime/check_jni.cc:70] | held mutexes= "mutator lock"(shared held)
08-04 17:11:07.529 2447-2505/com.shares.sdk.pvsdkapitest A/art: art/runtime/check_jni.cc:70] (no managed stack frames)
问题原因: _voltagesArray是数组, SetObjectField应该给数组那个field赋值,付错了
jclass gpicls=sdkenv->GetObjectClass(batteryStatusobj);
jfieldID jvoltages = sdkenv->GetFieldID(gpicls, "voltages", "[S");
jfieldID jbattery_remaining = sdkenv->GetFieldID(gpicls, "battery_remaining", "B");
jfieldID jtemperature = sdkenv->GetFieldID(gpicls, "temperature", "S");
jshortArray _voltagesArray=sdkenv->NewShortArray(sizeof(info.voltages));
//memcpy(_voltagesArray,info.voltages,sizeof(info.voltages));
sdkenv->SetShortArrayRegion(_voltagesArray,0,9,(jshort *)info.voltages);
sdkenv->SetObjectField( batteryStatusobj,jvoltages,_voltagesArray);—— 这里错了,应该是jvoltages
sdkenv->SetByteField(batteryStatusobj, jbattery_remaining,info.battery_remaining);
sdkenv->SetShortField(batteryStatusobj, jtemperature,info.temperature);
sdkenv->CallVoidMethod(globalcallBack, jmid, info,batteryStatusobj);
文章来源: blog.csdn.net,作者:网奇,版权归原作者所有,如需转载,请联系作者。
原文链接:blog.csdn.net/jacke121/article/details/61419695
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)