Reputation: 925
I am developing an android application including native code
First I compile a prebuilt library. The Android.mk file is 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)
Then I compile my library whose the Android.mk file is 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)
When I compile the jni folder using the ndk-build script, everything works well but get the following error when calling :
static {
System.loadLibrary("myLibrary");
}
java.lang.UnsatisfiedLinkError: JNI_ERR returned from JNI_OnLoad in "/data/app/com.example.qtsignaux-1/lib/arm/libmyLibrary.so"
Notice I unziped the apk folder and every libaries : libQt5Core.so, libmyLibrary.so and libgnustl_shared.so are in the lib/armeabi/ and lib/armeabi-v7a/ folders
My Application.mk file looks like :
APP_ABI += armeabi armeabi-v7a
APP_STL := gnustl_shared
APP_CPPFLAGS := -frtti -fexceptions
I don't really understand what the error means and why the system try to load a library in the application_package_name/lib/arm folder. Does this folder really exist or this is just armeabi and armeabi-v7a in my situation?
Thank you in advance for your help
Upvotes: 2
Views: 14676
Reputation: 925
I finally fixed my problem. This was because of libQt5Core.so file
Indeed this library implements the JNI_OnLoad() function in which it tries to load some java classes contained in an external jar file.
To solve my problem I included the right jar file in the /libs
Upvotes: 3