我正在尝试将百度Map SDK集成到我的Android应用程序中。

库的结构:

android - 初始化百度 map SDK时出现UnsatisfiedLinkError-LMLPHP

导致此代码出现问题:

SDKInitializer.initialize(applicationContext)

错误日志:
    03-27 00:57:26.557 18050-18050/com.emerson.oversight E/NativeLoader: found libBaiduMapSDK_base_v4_5_2.so error
03-27 00:57:26.558 18050-18050/com.emerson.oversight E/art: No implementation found for int com.baidu.platform.comjni.tools.JNITools.initClass(java.lang.Object, int) (tried Java_com_baidu_platform_comjni_tools_JNITools_initClass and Java_com_baidu_platform_comjni_tools_JNITools_initClass__Ljava_lang_Object_2I)
03-27 00:57:26.560 18050-18050/com.emerson.oversight D/AndroidRuntime: Shutting down VM


    --------- beginning of crash
03-27 00:57:26.562 18050-18050/com.emerson.oversight E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.emerson.oversight, PID: 18050
    java.lang.UnsatisfiedLinkError: No implementation found for int com.baidu.platform.comjni.tools.JNITools.initClass(java.lang.Object, int) (tried Java_com_baidu_platform_comjni_tools_JNITools_initClass and Java_com_baidu_platform_comjni_tools_JNITools_initClass__Ljava_lang_Object_2I)
        at com.baidu.platform.comjni.tools.JNITools.initClass(Native Method)
        at com.baidu.platform.comjni.tools.a.b(Unknown Source)
        at com.baidu.platform.comapi.a.<clinit>(Unknown Source)
        at com.baidu.platform.comapi.a.a(Unknown Source)
        at com.baidu.platform.comapi.c.a(Unknown Source)
        at com.baidu.mapapi.SDKInitializer.initialize(Unknown Source)
        at com.baidu.mapapi.SDKInitializer.initialize(Unknown Source)
        at oversight.controller.ui.activities.BaiduMapActivity.onCreate(BaiduMapActivity.kt:84)
        at android.app.Activity.performCreate(Activity.java:6977)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2946)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3064)
        at android.app.ActivityThread.-wrap14(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1659)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6823)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1563)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1451)
lll

最佳答案

应用程序级别(而非顶级级别)的build.gradle文件应为:

apply plugin: 'com.android.application'

repositories {
    flatDir {
        dir 'libs'
    }
}

android {

    // Stuff ...

    sourceSets {
        main {
            jniLibs.srcDir 'libs'
        }
    }

   // Stuff ...
}

dependencies {

    compile fileTree(dir: 'libs', include: ['*.jar'])

    // Stuff..
}

07-27 23:41