harveyslash
harveyslash

Reputation: 6012

Unable to build Mupdf for android(ExceptionInitializerError)

I wanted to use MuPDF for my android application. To build it, I downloaded the source, cygwin and android ndk.

After saving ndk and MUPDF source to my F:\ drive, I ran this:

Prepare the source

Check out a copy of the mupdf source from git:

~/src $ git clone git://git.ghostscript.com/mupdf.git Check out the third party library submodules:

~/src/mupdf $ git submodule update --init Populate the generated directory with the necessary files:

~/src/mupdf $ make generate Build and debug

Change into the platform/android directory and edit the local properties configuration file.

~/src/mupdf $ cd platform/android ~/src/mupdf/platform/android $ cp local.properties.sample local.properties ~/src/mupdf/platform/android $ nano local.properties

Another note, after copying the local.properties, I added this line:

sdk.dir=D:\\adt-bundle-windows-x86\\sdk

Where D:\adt-bundle-windows-x86\sdk is where my android sdk is located.

I got the above from the MuPDF site itself. While building the source, I got this : Possible error while building

After that, I imported the code from mupdf/source/platform/android/ to my eclipse workspace.The project builds fine and the pdf chooser opens as it should;But when I choose some pdf, it crashes with the following error:

06-15 10:34:43.267: E/AndroidRuntime(16870): FATAL EXCEPTION: main 06-15 10:34:43.267: E/AndroidRuntime(16870): java.lang.ExceptionInInitializerError 06-15 10:34:43.267: E/AndroidRuntime(16870): at com.artifex.mupdfdemo.MuPDFActivity.openFile(MuPDFActivity.java:213) 06-15 10:34:43.267: E/AndroidRuntime(16870): at com.artifex.mupdfdemo.MuPDFActivity.onCreate(MuPDFActivity.java:309) 06-15 10:34:43.267: E/AndroidRuntime(16870): at android.app.Activity.performCreate(Activity.java:5008) 06-15 10:34:43.267: E/AndroidRuntime(16870): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079) 06-15 10:34:43.267: E/AndroidRuntime(16870): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023) 06-15 10:34:43.267: E/AndroidRuntime(16870): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084) 06-15 10:34:43.267: E/AndroidRuntime(16870): at android.app.ActivityThread.access$600(ActivityThread.java:130) 06-15 10:34:43.267: E/AndroidRuntime(16870): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195) 06-15 10:34:43.267: E/AndroidRuntime(16870): at android.os.Handler.dispatchMessage(Handler.java:99) 06-15 10:34:43.267: E/AndroidRuntime(16870): at android.os.Looper.loop(Looper.java:137) 06-15 10:34:43.267: E/AndroidRuntime(16870): at android.app.ActivityThread.main(ActivityThread.java:4745) 06-15 10:34:43.267: E/AndroidRuntime(16870): at java.lang.reflect.Method.invokeNative(Native Method) 06-15 10:34:43.267: E/AndroidRuntime(16870): at java.lang.reflect.Method.invoke(Method.java:511) 06-15 10:34:43.267: E/AndroidRuntime(16870): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 06-15 10:34:43.267: E/AndroidRuntime(16870): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 06-15 10:34:43.267: E/AndroidRuntime(16870): at dalvik.system.NativeStart.main(Native Method) 06-15 10:34:43.267: E/AndroidRuntime(16870): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load mupdf: findLibrary returned null 06-15 10:34:43.267: E/AndroidRuntime(16870): at java.lang.Runtime.loadLibrary(Runtime.java:365) 06-15 10:34:43.267: E/AndroidRuntime(16870): at java.lang.System.loadLibrary(System.java:535) 06-15 10:34:43.267: E/AndroidRuntime(16870): at com.artifex.mupdfdemo.MuPDFCore.(MuPDFCore.java:14)

What is going wrong here ? I am using cygwin and I am running windows 7.

I plan to use mupdf as a library for rendering pdfs

Upvotes: 2

Views: 787

Answers (1)

epiphany27
epiphany27

Reputation: 517

Your logcat clearly shows that it is "Caused by: java.lang.UnsatisfiedLinkError: Couldn't load mupdf: ", i.e., it failed because it's unable to load "libmupdf.so" library.

Make sure you have correctly followed all steps on the MuPDF documentation page . Ensure that all commands ran successfully without giving any errors. Looking at your terminal (command prompt) screenshot, it seems that ""make" command failed.

After ndk-build step, "libmupdf.so" must be generated. Make sure it's there in your Android-Project-Folder/libs/armeabi-v7a/

Upvotes: 1

Related Questions