Android: Couldn't load mupdf

1k views Asked by At

I am having an (Android Studio - Gradle) Cordova (3.6.4) project.

In my app there can be a list of pdf files which should be shown with mupdf. But I always get the following error message:

06-10 15:04:38.365    5940-5940/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: de.dil.DSM, PID: 5940
    java.lang.UnsatisfiedLinkError: Couldn't load mupdf from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/de.dil.DSM-2.apk"],nativeLibraryDirectories=[/data/app-lib/de.dil.DSM-2, /vendor/lib, /system/lib]]]: findLibrary returned null
            at java.lang.Runtime.loadLibrary(Runtime.java:358)
            at java.lang.System.loadLibrary(System.java:526)
            at com.artifex.mupdfdemo.MuPDFCore.<clinit>(MuPDFCore.java:14)
            at de.dil.DSM.DSM.loadFile(DSM.java:216)
            at de.dil.DSM.xviewer$6.run(xviewer.java:102)
            at android.os.Handler.handleCallback(Handler.java:733)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5001)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
            at dalvik.system.NativeStart.main(Native Method)

The java files from mupdf seems to be correctly imported.

It seems to be, that it is "just" the "libmupdf.so" which isn't correctly imported.

The libmupdf.so files are in the following directories:

  • libs/armeabi/libmupdf.so
  • libs/armeabi-v7a/libmupdf.so

There is also a c mupdf file here: jni/mupdf.c

Is there anything which I especially need to configure in the settings.gradle or in the build.gradle?

Thanks ahead!!!!

2

There are 2 answers

0
Médéric On

Put your .so files in a jniLibs folder

>src
  >main
    >jniLibs
      >armeabi
        |libmupdf.so
      >armeabi-v7a
        |libmupdf.so
0
mbo On

The solution was to add this:

jniLibs.srcDirs = ['libs']

To the existing sourceSets in the build.gradle!