Android接入高德地图SDK时报错JNI DETECTED ERROR IN APPLICATION: fid == null

Android接入amap高德地图SDK时报错:

JNI DETECTED ERROR IN APPLICATION: fid == null    

in call to GetBooleanField  

from java.lang.Object com.autonavi.base.amap.mapcore.AMapNativeGlOverlayLayer.nativeGetNativeOverlayProperties(java.lang.String, java.lang.String, java.lang.Object[])

No pending exception expected: java.lang.NoSuchFieldError: no "Z" field "value" in class "Ljava/lang/Boolean;" or its superclasses


解决方案:targetSdkVersion 28      或  < 28

当然,这是当下时间段(2021.04)和当前依赖 implementation 'com.amap.api:3dmap:7.9.0' (对应.so文件:libAMapSDK_MAP_v7_9_0.so)的解决方案,当前最新版本的高德地图SDK提供的.so库文件不兼容 targetSdkVersion 28以上的API level。但有可能经过一段时间,官方SDK提供的.so库更新后支持了 targetSdkVersion 29 或更高版本,这个错误应该也就不会出现了。


问题详情如下:

build.gradle中引入的依赖如下:

//定位功能
implementation 'com.amap.api:location:5.3.1'
//3D地图(含.so库)
implementation 'com.amap.api:3dmap:7.9.0'
//地图搜索
implementation 'com.amap.api:search:7.9.0'

添加高德地图常用功能,在模拟器上没有任何问题。

在真机上,地图能正常展示出来,但是放大缩小拖动时会崩溃闪退。(刚接入时也没有问题,还调试了一个小时UI呢,可过了个周末,就出这个问题了,郁闷!)

详细报错日志如下:

2021-04-06 18:25:51.554 1763-1763/com.amituo.bian A/com.amituo.bia: java_vm_ext.cc:570] JNI DETECTED ERROR IN APPLICATION: fid == null
2021-04-06 18:25:51.554 1763-1763/com.amituo.bian A/com.amituo.bia: java_vm_ext.cc:570]     in call to GetBooleanField
2021-04-06 18:25:51.554 1763-1763/com.amituo.bian A/com.amituo.bia: java_vm_ext.cc:570]     from java.lang.Object com.autonavi.base.amap.mapcore.AMapNativeGlOverlayLayer.nativeGetNativeOverlayProperties(java.lang.String, java.lang.String, java.lang.Object[])
2021-04-06 18:25:51.652 1763-1763/com.amituo.bian A/com.amituo.bia: thread.cc:2544] No pending exception expected: java.lang.NoSuchFieldError: no "Z" field "value" in class "Ljava/lang/Boolean;" or its superclasses
2021-04-06 18:25:51.652 1763-1763/com.amituo.bian A/com.amituo.bia: thread.cc:2544]   at java.lang.Object com.autonavi.base.amap.mapcore.AMapNativeGlOverlayLayer.nativeGetNativeOverlayProperties(java.lang.String, java.lang.String, java.lang.Object[]) (AMapNativeGlOverlayLayer.java:-2)
2021-04-06 18:25:51.652 1763-1763/com.amituo.bian A/com.amituo.bia: thread.cc:2544]   at java.lang.Object com.autonavi.base.amap.mapcore.AMapNativeGlOverlayLayer.getNativeProperties(java.lang.String, java.lang.String, java.lang.Object[]) (AMapNativeGlOverlayLayer.java:223)
2021-04-06 18:25:51.652 1763-1763/com.amituo.bian A/com.amituo.bia: thread.cc:2544]   at void com.amap.api.mapcore.util.q.setFlingState(boolean) (GlOverlayLayer.java:844)
2021-04-06 18:25:51.652 1763-1763/com.amituo.bian A/com.amituo.bia: thread.cc:2544]   at void com.amap.api.mapcore.util.b$1.handleMessage(android.os.Message) (AMapDelegateImp.java:580)
2021-04-06 18:25:51.652 1763-1763/com.amituo.bian A/com.amituo.bia: thread.cc:2544]   at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:110)
2021-04-06 18:25:51.652 1763-1763/com.amituo.bian A/com.amituo.bia: thread.cc:2544]   at void android.os.Looper.loop() (Looper.java:219)
2021-04-06 18:25:51.652 1763-1763/com.amituo.bian A/com.amituo.bia: thread.cc:2544]   at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:8387)
2021-04-06 18:25:51.652 1763-1763/com.amituo.bian A/com.amituo.bia: thread.cc:2544]   at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
2021-04-06 18:25:51.653 1763-1763/com.amituo.bian A/com.amituo.bia: thread.cc:2544]   at void com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run() (RuntimeInit.java:513)
2021-04-06 18:25:51.653 1763-1763/com.amituo.bian A/com.amituo.bia: thread.cc:2544]   at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:1055)
2021-04-06 18:25:51.653 1763-1763/com.amituo.bian A/com.amituo.bia: thread.cc:2544] 
2021-04-06 18:25:51.803 1763-1763/com.amituo.bian A/com.amituo.bia: runtime.cc:663] Runtime aborting --- recursively, so no thread-specific detail!
2021-04-06 18:25:51.804 1763-1763/com.amituo.bian A/com.amituo.bia: runtime.cc:663] #00 pc 0030b017  /apex/com.android.runtime/lib/libart.so (art::DumpNativeStack(std::__1::basic_ostream>&, int, BacktraceMap*, char const*, art::ArtMethod*, void*, bool)+78)
2021-04-06 18:25:51.804 1763-1763/com.amituo.bian A/com.amituo.bia: runtime.cc:663] #01 pc 003959bf  /apex/com.android.runtime/lib/libart.so (art::Runtime::Abort(char const*)+1254)
2021-04-06 18:25:51.804 1763-1763/com.amituo.bian A/com.amituo.bia: runtime.cc:663] #02 pc 000085e1  /system/lib/libbase.so (android::base::LogMessage::~LogMessage()+488)
2021-04-06 18:25:51.804 1763-1763/com.amituo.bian A/com.amituo.bia: runtime.cc:663] #03 pc 003ccd27  /apex/com.android.runtime/lib/libart.so (art::Thread::AssertNoPendingException() const+818)
2021-04-06 18:25:51.804 1763-1763/com.amituo.bian A/com.amituo.bia: runtime.cc:663] #04 pc 00101e27  /apex/com.android.runtime/lib/libart.so (art::ClassLinker::FindClass(art::Thread*, char const*, art::Handle)+30)
2021-04-06 18:25:51.804 1763-1763/com.amituo.bian A/com.amituo.bia: runtime.cc:663] #05 pc 000f40ef  /apex/com.android.runtime/lib/libart.so (art::ClassLinker::DoResolveType(art::dex::TypeIndex, art::Handle, art::Handle)+122)
2021-04-06 18:25:51.804 1763-1763/com.amituo.bian A/com.amituo.bia: runtime.cc:663] #06 pc 003eb40d  /apex/com.android.runtime/lib/libart.so (_ZN3art8verifier4impl12_GLOBAL__N_114MethodVerifierILb0EE6VerifyEv$09bf97eb2c0d684adb6d215f7005036e+1164)
2021-04-06 18:25:51.804 1763-1763/com.amituo.bian A/com.amituo.bia: runtime.cc:663] #07 pc 003ee163  /apex/com.android.runtime/lib/libart.so (art::verifier::MethodVerifier::FindLocksAtDexPc(art::ArtMethod*, unsigned int, std::__1::vector>*, unsigned int)+470)
2021-04-06 18:25:51.804 1763-1763/com.amituo.bian A/com.amituo.bia: runtime.cc:663] #08 pc 00308421  /apex/com.android.runtime/lib/libart.so (art::Monitor::VisitLocks(art::StackVisitor*, void (*)(art::ObjPtr, void*), void*, bool)+408)
2021-04-06 18:25:51.804 1763-1763/com.amituo.bian A/com.amituo.bia: runtime.cc:663] #09 pc 00308f95  /apex/com.android.runtime/lib/libart.so (art::MonitorObjectsStackVisitor::VisitFrame()+96)

最初以为是.so库的问题,官方开发文档上也有说 .so 库文件的类似问题,但是经验证,通过添加依赖 implementation 'com.amap.api:3dmap:7.9.0'中包含的.so库 和 jniLibs 中添加对应的.so库,都是能正常打包进apk。

最后,对比高德地图官方demo,发现 targetSdkVersion 28  或 小于28的才好使。(花费了一天的时间,走了好多弯路,才发现这个问题 -_-|| )

你可能感兴趣的:(♠,Android,……【进阶篇】,android,.so,高德地图sdk,地图)