我正在开发一个包含本机代码的 android 应用程序
首先我编译一个预建库。Android.mk 文件是project_path/jni/qt-library/Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := qt5Core-prebuilt
LOCAL_SRC_FILES := libQt5Core.so
LOCAL_EXPORT_C_INCLUDES += qtbase/include
include $(PREBUILT_SHARED_LIBRARY)
然后我编译我的库,其 Android.mk 文件是project_path/jni/my-library/Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := myLibrary
LOCAL_SRC_FILES := com_example_qtsignaux_Library.cpp
LOCAL_SRC_FILES += Receiver.cpp
LOCAL_SRC_FILES += Emitter.cpp
LOCAL_SRC_FILES += moc_Receiver.cpp
LOCAL_SRC_FILES += moc_Emitter.cpp
LOCAL_SHARED_LIBRARIES := qt5Core-prebuilt
LOCAL_C_INCLUDES += ../qt-library/qtbase/include
LOCAL_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)
当我使用 ndk-build 脚本编译 jni 文件夹时,一切正常,但调用时出现以下错误:
static {
System.loadLibrary("myLibrary");
}
java.lang.UnsatisfiedLinkError: JNI_ERR returned from JNI_OnLoad in "/data/app/com.example.qtsignaux-1/lib/arm/libmyLibrary.so"
请注意,我解压缩了 apk 文件夹和每个库:libQt5Core.so、libmyLibrary.so 和 libgnustl_shared.so在 lib/armeabi/ 和 lib/armeabi-v7a/ 文件夹中
我的 Application.mk 文件如下所示:
APP_ABI += armeabi armeabi-v7a
APP_STL := gnustl_shared
APP_CPPFLAGS := -frtti -fexceptions
我真的不明白错误的含义以及系统为什么尝试在application_package_name/lib/ arm文件夹中加载库。这个文件夹是否真的存在,或者在我的情况下这只是 armeabi 和 armeabi-v7a?
预先感谢您的帮助