System.loadLibrary(...) could not find native library in my case

asked 2016-06-07 02:30:10 -0500

elish gravatar image

updated 2016-06-07 02:30:37 -0500

I want to create a simple android project using native libs,
I copied existing native library from another Android project into my android project under jniLibs folder.
I am new in this, i will appreciate any help,

In my java code I load the library by:

public native String helloWorld();
static{
    System.loadLibrary("ndktest");
}

When I run my new android project, I got an error:

java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.benzy.finalimage-2/base.apk"],nativeLibraryDirectories=[/data/app/com.example.benzy.finalimage-2/lib/x86, /vendor/lib, /system/lib]]] couldn't find "libndktest.so"

And i don't have that file nowhere in my project.

The content of Android.mk is:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := ndktest

LOCAL_SRC_FILES := ndktest.c

include $(BUILD_SHARED_LIBRARY)

The content of Application.mk is:

APP_ABI := all

And my ndktest.c file is:

#include <jni.h>
#include <string.h>

jstring java_com_example_benzy_finalimage_MainActivity_helloWorld(JNIEnv* env,jobject obj){

      return (*env)->NewStringUTF(env,"hello world jni");
}

Thank you all.

edit retag flag offensive close merge delete