当我在我的Android应用程序中集成Cardboard时出现以下错误。 (我在Samsung S6 / Note 3 / Nexus 6上运行它)
... D/CardboardViewNativeImpl﹕ NativeProxy not found
... D/CardboardViewNativeImpl﹕ Loading native library vrtoolkit
... D/CardboardViewNativeImpl﹕ Native library loaded
... W/art﹕ Attempt to remove local handle scope entry from IRT, ignoring
... W/art﹕ Attempt to remove local handle scope entry from IRT, ignoring
... W/art﹕ Attempt to remove local handle scope entry from IRT, ignoring
... A/art﹕ art/runtime/check_jni.cc:65] JNI DETECTED ERROR IN APPLICATION: GetMethodID received null jclass
... A/art﹕ art/runtime/check_jni.cc:65] in call to GetMethodID
... A/art﹕ art/runtime/check_jni.cc:65] from long com.google.vrtoolkit.cardboard.CardboardViewNativeImpl.nativeInit(int, int, float, float, float, long)
... A/art﹕ art/runtime/check_jni.cc:65] "main" prio=5 tid=1 Runnable
... A/art﹕ art/runtime/check_jni.cc:65] | group="main" sCount=0 dsCount=0 obj=0x73617000 self=0xb4827800
... A/art﹕ art/runtime/check_jni.cc:65] | sysTid=24304 nice=0 cgrp=default sched=0/0 handle=0xb6f04bec
... A/art﹕ art/runtime/check_jni.cc:65] | state=R schedstat=( 1668176075 289166273 1700 ) utm=148 stm=18 core=1 HZ=100
... A/art﹕ art/runtime/check_jni.cc:65] | stack=0xbe04a000-0xbe04c000 stackSize=8MB
... A/art﹕ art/runtime/check_jni.cc:65] | held mutexes= "mutator lock"(shared held)
我还添加了abiFilters,因为cardbaord.jar文件只有armeabi-v7a的.so文件。但仍然得到错误。
buildTypes {
debug {
...
ndk {
abiFilters "armeabi-v7a" // includes ARM SO files only, so no x86 SO file
}
}
我能够创建一个独立的cardbaord应用程序并在所有三个设备上运行它而不会出现问题,只有当我与现有应用程序集成时才会在运行时失败。
答案 0 :(得分:2)
我有这个完全相同的问题,当它是独立的时它可以工作,但是当我将它集成到现有应用程序时,“GetMethodID收到null jclass”会中断。
事实证明我在集成应用程序中启用了ProGuard,添加了以下规则修复它:
-keep class com.google.vrtoolkit.cardboard.** { *; }
答案 1 :(得分:0)
对于新的Cardboard SDK 0.8.0,我必须添加以下ProGuard规则:
-keep class com.google.vr.**
-keepclassmembers class com.google.vr.** { *; }
-keep class com.google.vr.**$*
-keepclassmembers class com.google.vr.**$* { *; }
-keep class com.google.geo.render.**
-keepclassmembers class com.google.geo.render.** { *; }
# Also keept this rule, just in case (probably only needed for 0.7.0)
-keep class com.google.vrtoolkit.cardboard.** { *; }
我有点匆忙,因为那可能我已经太过保守"关于规则。我已经在 panowidget (静态图片)和视频聊天(视频)示例中进行了检查,它在两种情况下都有效。