Android Studio - UnsatisfiedLinkError for prebuilt native library -


i'm trying implement soundtouch c++ library android project.

gradle build works fine. but, when call soundtouch related method code, app crashes , following error:

caused by: java.lang.unsatisfiedlinkerror: dalvik.system.pathclassloader[dexpathlist[[zip file "/data/app/com.dancam.chords-1/base.apk"],nativelibrarydirectories=[/data/app/com.dancam.chords-1/lib/arm64, /system/lib64, /vendor/lib64]]] couldn't find "libsoundtouch.so"

apparently not find libsoundtouch.so within libs arm64 folder. file tree looks this:

filetree

any clue why happens?

edit:

i copied soundtouch.java class in main/java/net/surina/soundtouch

still when run this:

caused by: java.lang.unsatisfiedlinkerror: no implementation found long soundtouch.soundtouch.newinstance() (tried java_soundtouch_soundtouch_newinstance , java_soundtouch_soundtouch_newinstance__)

as if in soundtouch folder.

this how project dir looks like:

filetree2

i tried cleaning , rebuilding project no luck

tl;nr: rename app/libs folder app/jnilibs.


when use prebuilt libraries, must instruct android studio can find them. default location jnilibs under module root directory.

you can instruct android studio pick libraries elsewhere: add following android {} block in build.gradle script module (app):

sourcesets.main.jnilibs.srcdirs = ['libs', 'src/main/jnilibs', '/absolute/path/to/prebuilt'] 

each jnilibs src directory expected have subdirectories lib××××.so files in them: arm64-v8a armeabi armeabi-v7a mips mips64 x86 x86_64. not abi subdirectories must present, , have further control abis used apk, ndk.abifilters flag.

as can see, can pick more 1 set of libraries, , pack lib××××.so files apk. may fail if there conflict (e.g. finds both libs/x86/libqq.so , absolute/path/to/prebuilt/libqq.so), doesn't care if files under x86, armeabi, mips64 have relationship between them.


when use prebuilt c++ library in java (e.g. android) application, must keep names of java classes (including package names) commanded native code.

for example, soundtouch library should accessed net/surina/soundtouch/soundtouch.java.

you can use whatever app package name; keep java classes have native methods.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -