Issue
I am trying to use Android NDK. As a first step, I am trying to do the same thing as hello-jni from android samples. I created jni folder under project and placed hello-jni.c, Android.mk, Application.mk. I built the c file using ndk-build. It built and placed .so files under libs directory and couple of arm* directory. But when I used
static {
System.loadLibrary("hello-jni");
}
within my activity, I am getting
10-22 22:58:12.248 2291-2291/? E/AndroidRuntime: java.lang.UnsatisfiedLinkError: Couldn't load hello-jni from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.clinicloud.app.ndktestapp-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.clinicloud.app.ndktestapp-1, /system/lib]]]: findLibrary returned null
10-22 22:58:12.248 2291-2291/? E/AndroidRuntime: at java.lang.Runtime.loadLibrary(Runtime.java:355)
10-22 22:58:12.248 2291-2291/? E/AndroidRuntime: at java.lang.System.loadLibrary(System.java:525)
10-22 22:58:12.248 2291-2291/? E/AndroidRuntime: at com.clinicloud.app.ndktestapp.MainActivity.<clinit>(MainActivity.java:56)
10-22 22:58:12.248 2291-2291/? E/AndroidRuntime: at java.lang.Class.newInstanceImpl(Native Method)
My Android.mk File
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := hello-jni
LOCAL_SRC_FILES := hello-jni.c
include $(BUILD_SHARED_LIBRARY)
My Application.mk file includes,
APP_ABI := all
The .so files are named libhello-jni.so
Can someone help me out to fix this? Thanks.
UPDATE
I fixed this issue by placing the below code in my build.gradle.
sourceSets.main {
jniLibs.srcDir 'libs'
}
Solution
Make sure that libhello-jni.so is compiled and place under /libs/[ARCH] in your project. You can also unzip your apk and see if the library is there.
Answered By - Krypton
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.