Android 无法导入两个库

Android Can't Import Two Libraries

我正在尝试创建一个 android 应用程序,它使用 android 的 CNU Project Sphinx 库和 android 的 Spotify 库。我可以在单独的项目中很好地实现这些库,但是当我尝试将它们组合成一个时,出现错误:

14178-14178/com.tmacstudios.spotifyvoice E/AndroidRuntime: FATAL EXCEPTION: main
  Process: com.tmacstudios.spotifyvoice, PID: 14178
  java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.tmacstudios.spotifyvoice-2/base.apk"],nativeLibraryDirectories=[/data/app/com.tmacstudios.spotifyvoice-2/lib/arm64, /vendor/lib64, /system/lib64]]] couldn't find "libgnustl_shared.so"
      at java.lang.Runtime.loadLibrary(Runtime.java:367)
      at java.lang.System.loadLibrary(System.java:988)
      at com.spotify.sdk.android.player.NativeSdkPlayer.nativeInit(NativeSdkPlayer.java:44)
      at com.spotify.sdk.android.player.NativeSdkPlayer.<clinit>(NativeSdkPlayer.java:34)
      at com.spotify.sdk.android.player.Player.<init>(Player.java:310)
      at com.spotify.sdk.android.player.Player.create(Player.java:356)
      at com.spotify.sdk.android.player.Player.access[=11=]0(Player.java:86)
      at com.spotify.sdk.android.player.Player$Builder.build(Player.java:282)
      at com.spotify.sdk.android.player.Spotify.getPlayer(Spotify.java:110)
      at com.spotify.sdk.android.player.Spotify.getPlayer(Spotify.java:76)
      at edu.cmu.pocketsphinx.demo.PocketSphinxActivity.onActivityResult(PocketSphinxActivity.java:272)
      at android.app.Activity.dispatchActivityResult(Activity.java:6758)
      at android.app.ActivityThread.deliverResults(ActivityThread.java:4726)
      at android.app.ActivityThread.handleSendResult(ActivityThread.java:4773)
      at android.app.ActivityThread.access00(ActivityThread.java:205)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1744)
      at android.os.Handler.dispatchMessage(Handler.java:102)
      at android.os.Looper.loop(Looper.java:145)
      at android.app.ActivityThread.main(ActivityThread.java:6895)
      at java.lang.reflect.Method.invoke(Native Method)
      at java.lang.reflect.Method.invoke(Method.java:372)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)

有谁知道如何解决这个问题?我不确定还包括什么,所以这是我的 build.gradle 文件 Module:app -

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.tmacstudios.spotifyvoice"
        minSdkVersion 21
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

repositories {
    mavenCentral()
    flatDir {
        dirs 'libs'
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'

    // This library handles authentication and authorization
    compile 'com.spotify.sdk:spotify-auth:1.0.0-beta12@aar'

    // This library handles music playback
    compile 'com.spotify.sdk:spotify-player:1.0.0-beta12@aar'

    // All other dependencies for your app should also be here:

    compile 'com.android.support:appcompat-v7:21.0.3'
}

感谢您的帮助。

为了更清楚地显示我的问题的答案,以下是解决我问题的评论线程中的信息:

My guess is that they both have NDK libraries, but they have a varying set of CPU architectures that they support. Particularly for devices with 64-bit CPUs, Android wants to use a consistent set of libraries: all 64-bit or all 32-bit. So, if one library publishes 64-bit and another publishes only 32-bit, somebody loses, and IIRC it's the 32-bit-only publisher. Examine the contents of each library and see what CPU architectures seem to be supported. Come up with a common subset. -CommonsWare

You were spot on. Spotify only defines jni libraries for armeabi, armeabi-v7a, and x86, so I deleted the extraneous architecture libraries that were supported by Sphinx and it worked.-我

感谢解答!

我的项目运行良好,但使用的是 Spotify aar。 当我添加 deezer aar 时,我的 phone 64b 就崩溃了。

他们不支持相同的架构看屏幕:

所以我不得不从 deezer aar 中手动删除附加功能以使其正常工作: