Search code examples
androidandroid-ndkunsatisfiedlinkerrorqtcore

Android - UnsatisfiedLinkError: unknown failure loading libQt5Core.so


This is the first time I decided to write here, but I have long time successfully used stackoverflow, thanks to people who spend his time helping others! :)

Now, I have not found information about this, I am trying to use a library which uses Qt in my android application. The problem is that I am not able to load libQt5Core.so. When running Android throw an unsatisfiedLinkError: unknown failure. I have tried to load it in two ways.
First one, with its own Android.mk:

LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := Qt5Core
LOCAL_SRC_FILES := $(TARGET_ARCH_ABI)/libQt5Core.so
LOCAL_EXPORT_C_INCLUDES :=  $(LOCAL_PATH)/include \
                            $(LOCAL_PATH)/include/QtCore
include $(PREBUILT_SHARED_LIBRARY)

Second one, adding it manually to lib dir.

I load libraries froma Native.java file in this way:

System.loadLibrary("gnustl_shared");
System.loadLibrary("Qt5Core");
System.loadLibrary("mysharedlibray");
System.loadLibrary("thewholelibrary");

I mysharedlibrary with a Makefile, it's the library which uses Qt. The whole library includes the jni code and mysharedlibrary, I make it using ndk-build.

I have got libQt5Core.so from the Necessitas package, I suppose I can use it out from the Necessitas system.

I also would like make a "standalone shared library" mysharedlibrary with the Qt "inside" it (since I use no Qt at jni in Android" but it does not let me do that.

Thanks a lot!


Solution

  • I've found one solution:

    static {
        try {
            System.loadLibrary("gnustl_shared");
            System.loadLibrary("Qt5Core");
        } 
        catch( UnsatisfiedLinkError e ) {
            System.err.println("Native code library failed to load.\n" + e);
        }
        System.loadLibrary("mysharedlibray");
        System.loadLibrary("thewholelibrary");
    }
    

    If your library uses Qt but just inside itself that works.