Issue
I try to build an Android Project (ndk-build).
I´d like to use a precompiled library in my project. (libdemo.so)
Android.mk:
APP_STL := gnustl_static
APP_CPPFLAGS := -fexceptions
APP_ABI=armeabi armeabi-v7a
Application.mk:
LOCAL_PATH := $(call my-dir)
TARGET_ARCH_ABI := armeabi-v7a
include $(CLEAR_VARS)
LOCAL_MODULE := libdemo
LOCAL_SRC_FILES := $(TARGET_ARCH_ABI)/libdemo.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := native-lib
LOCAL_SRC_FILES := native-lib.cpp
LOCAL_SHARED_LIBRARIES := libdemo
include $(BUILD_SHARED_LIBRARY)
MainActivity:
android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
// Used to load the 'native-lib' library on application startup.
static {
System.loadLibrary("demo");
System.loadLibrary("native-lib");
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView tv = (TextView) findViewById(R.id.sample_text);
Log.d("TAG", stringFromJNI());
}
/**
* A native method that is implemented by the 'native-lib' native library,
* which is packaged with this application.
*/
public native String stringFromJNI();
}
But I get the following exception on build:
java.lang.UnsatisfiedLinkError: dlopen failed: library "/Users/John/Documents/Apps/LibTest/app/build/intermediates/ndkBuild/debug/obj/local/armeabi-v7a/libdemo.so" not found
The file exists on the provided path. I think the path at all isn´t correct. Why is there the path from my desktop pc? There should be a path from my device or?
Anyone here to help? Thanks
Solution
I solved the question by myself.
I don´t knew that ndk-build isn´t processed automatically. I had go to my project folder (folder where jni is present) and does ndk-build manually.
After that the libs are compiled and copied automatically in the /libs folder.
Now just build and run the app as usual and everything is fine.
Answered By - Stefan Deutschmann
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.