Oblivionkey3 Oblivionkey3 - 1 year ago 117
Android Question

Android Can't Import Two Libraries

I'm trying to create an android app that uses both the CNU Project Sphinx library for android and the Spotify library for android. I can implement the libraries fine in separate projects, but when I try and combine them into one, I get the error:

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$000(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.access$1500(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)

Does anyone know how to fix this? I'm not sure what else to include, so here's my build.gradle file for 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 {
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'

Thanks for your help.

Answer Source

Just to more clearly show the answer to my question, here's the information in the comment thread that solved my problem:

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. -Me

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download