百度定位
程序员文章站
2022-03-14 20:00:57
百度定位的垃圾之处:百度定位官方Demo, 下载解压后项目根目录是LocationDemo一. 填写申请的AK(app key)后,跑起来代码就崩溃。崩溃信息:E/NativeLoader: found lib armeabi/BaiduMapSDK_base_v6_3_0.so errorE/idulocationdem: No implementation found for int com.baidu.mapsdkplatform.comjni.tools.JNITools.initCl...
百度定位的垃圾之处:
百度定位官方Demo, 下载解压后项目根目录是LocationDemo
一. 填写申请的AK(app key)后,跑起来代码就崩溃。
- 崩溃信息:
E/NativeLoader: found lib armeabi/BaiduMapSDK_base_v6_3_0.so error
E/idulocationdem: No implementation found for int com.baidu.mapsdkplatform.comjni.tools.JNITools.initClass(java.lang.Object, int) (tried Java_com_baidu_mapsdkplatform_comjni_tools_JNITools_initClass and Java_com_baidu_mapsdkplatform_comjni_tools_JNITools_initClass__Ljava_lang_Object_2I)
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.baidu.baidulocationdemo, PID: 17572
java.lang.UnsatisfiedLinkError: No implementation found for int com.baidu.mapsdkplatform.comjni.tools.JNITools.initClass(java.lang.Object, int) (tried Java_com_baidu_mapsdkplatform_comjni_tools_JNITools_initClass and Java_com_baidu_mapsdkplatform_comjni_tools_JNITools_initClass__Ljava_lang_Object_2I)
at com.baidu.mapsdkplatform.comjni.tools.JNITools.initClass(Native Method)
at com.baidu.mapsdkplatform.comjni.tools.a.b(Unknown Source:6)
at com.baidu.mapsdkplatform.comapi.a.<clinit>(Unknown Source:23)
at com.baidu.mapsdkplatform.comapi.a.a(Unknown Source:0)
at com.baidu.mapsdkplatform.comapi.c.a(Unknown Source:17)
at com.baidu.mapapi.SDKInitializer.initialize(Unknown Source:2)
at com.baidu.location.demo.LocationApplication.onCreate(LocationApplication.java:30)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1190)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6571)
at android.app.ActivityThread.access$1400(ActivityThread.java:224)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1887)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:224)
at android.app.ActivityThread.main(ActivityThread.java:7551)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
- 崩溃原因:
找不到native
方法,那一定是是.so
文件的问题,找build.gradle
配置,确实没有cpu类型的配置:
defaultConfig {
applicationId "com.baidu.baidulocationdemo"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
ndk {
abiFilters 'armeabi','armeabi-v7a'/*,'arm64-v8a','x86','x86_64'*/
}
}
添加后,运行依然崩溃,在网上找了一圈有人说是.so
文件版本的问题,还别说,上面的崩溃信息第一条说的就是found lib armeabi/BaiduMapSDK_base_v6_3_0.so error
,那找一下这个so文件,结果代码里根本就没有,有的只是BaiduMapSDK_base_v6_1_0.so
,这个示例写的真是GOOD。
二. jar包和so包依赖的复杂。
从示例看,百度定位好像要依赖so文件,再看高德定位,只要一个AMap_Location_V4.8.0_20191210.jar
包可以。
不得不说,百度的定位集成真是垃圾。这里强烈推荐高德定位
,对于高德定位
的后台定位和息屏持续定位亲测在Android 10
上也没问题,这里为记录文档https://blog.csdn.net/u012551120/article/details/106421213
本文地址:https://blog.csdn.net/u012551120/article/details/107173864