私はこのリンクをたどりました
そして、次のようにフォルダー構造を作成しました
プロジェクト (プロジェクト ルート ディレクトリ)
|->src
|-->com.apparmtest
|--->MainActivity
|->jni
|-->Android.mk
|-->Application.mk
|-->AppARMTest.c
|- ->com_apparmtest_MainActivity.h
|->myLib
|-->FileTest.h
|-->libFRead.so
私の Android.mk ファイルの内容は
Android.mk
LOCAL_PATH := $(call my-dir)
### include FileTest.so as a prebuilt lib ###
include $(CLEAR_VARS)
LOCAL_MODULE := my-prebuilt-lib
LOCAL_SRC_FILES := ../myLib/libFRead.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../myLib
include $(PREBUILT_SHARED_LIBRARY)
### end prebuilt###
include $(CLEAR_VARS)
LOCAL_MODULE := AppARMTest
LOCAL_C_INCLUDES := $(LOCAL_PATH) \
$(LOCAL_PATH)/../myLib
LOCAL_SRC_FILES := AppARMTest.c
LOCAL_LDLIBS := -llog
LOCAL_STATIC_LIBRARIES := my-prebuilt-lib
include $(BUILD_SHARED_LIBRARY)
and my Application.mk contains
APP_MODULES := AppARMTest
APP_PLATFORM := ANDROID-8
and this project is compiling properly as well as ndk-build is not giving any error.
But while running on emmulator I am getting this error
10-19 10:25:40.704: E/AndroidRuntime(334): FATAL EXCEPTION: main
10-19 10:25:40.704: E/AndroidRuntime(334): java.lang.ExceptionInInitializerError
10-19 10:25:40.704: E/AndroidRuntime(334): at java.lang.Class.newInstanceImpl(Native Method)
10-19 10:25:40.704: E/AndroidRuntime(334): at java.lang.Class.newInstance(Class.java:1409)
10-19 10:25:40.704: E/AndroidRuntime(334): at
android.app.Instrumentation.newActivity(Instrumentation.java:1021)
10-19 10:25:40.704: E/AndroidRuntime(334): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
10-19 10:25:40.704: E/AndroidRuntime(334): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
10-19 10:25:40.704: E/AndroidRuntime(334): at
android.app.ActivityThread.access$1500(ActivityThread.java:117)
10-19 10:25:40.704: E/AndroidRuntime(334): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
10-19 10:25:40.704: E/AndroidRuntime(334): at
android.os.Handler.dispatchMessage(Handler.java:99)
10-19 10:25:40.704: E/AndroidRuntime(334): at android.os.Looper.loop(Looper.java:123)
10-19 10:25:40.704: E/AndroidRuntime(334): at
android.app.ActivityThread.main(ActivityThread.java:3683)
10-19 10:25:40.704: E/AndroidRuntime(334): at java.lang.reflect.Method.invokeNative(Native Method)
10-19 10:25:40.704: E/AndroidRuntime(334): at
java.lang.reflect.Method.invoke(Method.java:507)
10-19 10:25:40.704: E/AndroidRuntime(334): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
10-19 10:25:40.704: E/AndroidRuntime(334): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
10-19 10:25:40.704: E/AndroidRuntime(334): at dalvik.system.NativeStart.main(Native Method)
10-19 10:25:40.704: E/AndroidRuntime(334): Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: link_image[1962]: 33 could not load needed library
'./obj/local/armeabi/libFRead.so' for 'libAppARMTest.so' (load_library[1104]: Library './obj/local/armeabi/libFRead.so' not found)
10-19 10:25:40.704: E/AndroidRuntime(334): at java.lang.Runtime.loadLibrary(Runtime.java:434)
10-19 10:25:40.704: E/AndroidRuntime(334): at java.lang.System.loadLibrary(System.java:554)
10-19 10:25:40.704: E/AndroidRuntime(334): at ivz.apparmtest.MainActivity.<clinit>(MainActivity.java:11)
10-19 10:25:40.704: E/AndroidRuntime(334): ... 15 more