[Android] Baidu map use

Baidu map official website tutorial:
http://lbsyun.baidu.com/index.php?title=androidsdk/guide/create-project/attention

After opening the old project and updating to AndroidX, the error message is as follows:

2020-10-22 13:38:57.838 15332-15332/com.ding.admin.newfieldtest E/NativeLoader: found libBaiduMapSDK_base_v5_2_0.so error
2020-10-22 13:38:57.839 15332-15332/com.ding.admin.newfieldtest E/zygote64: 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)
2020-10-22 13:38:57.841 15332-15332/com.ding.admin.newfieldtest E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.ding.admin.newfieldtest, PID: 15332
    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.mapapi.SDKInitializer.initialize(Unknown Source:1)
        at com.ding.admin.newfieldtest.MainActivity.onCreate(MainActivity.java:178)

Solution reference:
https://blog.csdn.net/qq_32365567/article/details/70224862?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.add_param_isCf&depth_1-utm_source=distribute.pc_relev-ant.none-task blog-BlogCommendFromMachineLearnPai2-1.add_param_isCf

When an error like a certain .so file cannot be found, I have found several solutions, please write down for your reference.
One: The .so file does not match the jar package. I believe you will not commit this problem. This requires everyone to be careful, so I won't talk about it here.
2: Copy the libs file downloaded by Baidu directly into the project, there is an armeabi file that contains all the .so files. In this way, there will be no problem of not being able to find a certain .so file, and it will not report an error and run normally.
Three: If you think this is not good for the layout of the project, many people will create jniLibs files in src-main, and then put these armeabi resource files into it. But if this kind of error is reported after putting it in this way, then you need to delete sourceSets {main {jniLibs.srcDirs = ['libs'] }} in the buildGradle of the app. Of course you need dependencies {compile fileTree(include: ['*.jar'],dir:'libs')} here.
Four: If someone else ignores the jnilibs file when submitting the code, the .so file inside will not be submitted, and there will be no .so file after you update, and this error will be reported. First, check whether your project contains a .so file.

Insert picture description here

Insert picture description here

Guess you like

Origin blog.csdn.net/qq_30885821/article/details/109220653