Error while loading Native Library in Android -
i trying load native libraries in android studio. project build , runs throws error when trying load .so file.
my project structure is:
and gradle file is:
import com.android.build.gradle.tasks.packageapplication buildscript { repositories { mavencentral() } dependencies { classpath 'com.android.tools.build:gradle:1.2.3' } } apply plugin: 'com.android.application' repositories { mavencentral() } dependencies { compile 'com.nineoldandroids:library:2.4.0' compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar' compile 'com.android.support:support-v4:22.1.1' compile filetree(dir: 'libs', include: '*.jar') } android { compilesdkversion 19 buildtoolsversion '19.1.0' /* signingconfigs { release { storefile file(system.console().readline("\n\$ enter keystore path: ")) storepassword system.console().readline("\n\$ enter keystore password: ") keyalias system.console().readline("\n\$ enter key alias: ") keypassword system.console().readline("\n\$ enter key password: ") } } buildtypes { release { signingconfig signingconfigs.release } } */ getndkdirectory() defaultconfig { minsdkversion 10 targetsdkversion 22 } sourcesets { main { manifest.srcfile 'androidmanifest.xml' java.srcdirs = ['src'] resources.srcdirs = ['src'] aidl.srcdirs = ['src'] renderscript.srcdirs = ['src'] res.srcdirs = ['res'] assets.srcdirs = ['assets'] } instrumenttest.setroot('tests') } buildtypes { debug { debuggable true jnidebuggable true } } } /* * jni hack gradle - works alright, copies native libs on build folder no problem * https://gist.github.com/khernyo/4226923 */ task copynativelibs(type: copy) { from(new file('libs')) { include '**/*.so' } new file(builddir, 'native-libs') } tasks.withtype(javacompile) { options.encoding = "utf-8" } clean.dependson 'cleancopynativelibs' tasks.withtype(packageapplication) { pkgtask -> pkgtask.jnifolders = new hashset<file>() pkgtask.jnifolders.add(new file(projectdir, 'native-libs')) }
i trying load files like:
static { system.loadlibrary("nativeaudio"); }
i receive following error:
java.lang.unsatisfiedlinkerror: couldn't load plumble loader dalvik.system.pathclassloader[dexpathlist[[zip file "/mnt/asec/com.morlunk.mumbleclient-1/pkg.apk"],nativelibrarydirectories=[/mnt/asec/com.morlunk.mumbleclient-1/lib, /vendor/lib, /system/lib, /system/lib/arm]]]: findlibrary returned null
i tried many refrences unable solve issue. using android studio , gradle version: 1.2.3
unlike eclipse adt, gradle android plugin looks native libraries in src/main/jnilibs
folder default.
you can change folder location in following source set:
android { sourcesets.main { jnilibs.srcdir 'src/main/libs' } }
Comments
Post a Comment