Reputation: 87
i have a prebuilt libraries that contains jar files and .so files and i newly converted my project from eclipse to android studio my libs directory in eclipse is
libs ****armeabi
****x86
****jar files so armeabi and x86 contains the .so files and when i converted project to android studio the app build very well at first but some classes in the .so files are not initialized and giving error
java.lang.ExceptionInInitializerError Caused by: java.lang.UnsatisfiedLinkError: Couldn't load nmsp_speex from loader dalvik.system.PathClassLoader[dexPath=/data/app/project.app-2.apk,libraryPath=/data/app-lib/project.app-2]: findLibrary returned null
and i searched about this error , people says that you must add .so files in jni folder and a already did that ad found build error when android studio tried to build the ndk and the error says
Error:Execution failed for task ':project:compileDebugNdk'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'E:\Android Index\android-ndk-r10d\ndk-build.cmd'' finished with non-zero exit value 1
and here is my build.gradle file
apply plugin: 'android'
dependencies { compile fileTree(dir: 'libs', include: '*.jar') compile project(':appcompat') compile project(':facebook') compile project(':google-play-services_lib') compile project(':main') compile project(':pagerslidingtabstrip') compile 'com.android.support:multidex:1.0.0' } android { compileSdkVersion 21 buildToolsVersion "21.0.0" defaultConfig { minSdkVersion 9 targetSdkVersion 21 multiDexEnabled true }
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
jni.srcDirs = ['src/main/jni', 'src/main/jni/']
}
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
so any help on this
Upvotes: 1
Views: 1511
Reputation: 1731
I had the same issue.I placed my .so files under
src->
main->
jniLibs->armeabi-> .so file
and removed the line containing
jni.srcDirs = ['src/main/jni', 'src/main/jni/']
from my app's build.gradle.And it works fine.
Hope this helps someone.
Upvotes: 0
Reputation: 14473
if you don't have any NDK source code inside your project (you're not generating the .so files, you're only using them), then remove the jni folder and put your .so files into src/main/jniLibs/armeabi
and src/main/jniLibs/x86
.
btw you placed your ndk directory under a path that contains a space. You should move it to somewhere else or delete this blank space.
Upvotes: 0