无法为Android构建Mupdf(ExceptionInitializerError)

时间:2014-06-15 10:46:06

标签: android eclipse android-ndk java-native-interface mupdf

我想在我的Android应用程序中使用MuPDF。为了构建它,我下载了源码,cygwin和android ndk。

将ndk和MUPDF源保存到我的F:\驱动器后,我运行了这个:

  

准备来源

     

从git:

查看mupdf源代码的副本      

〜/ src $ git clone git://git.ghostscript.com/mupdf.git查看   第三方库子模块:

     

〜/ src / mupdf $ git submodule update --init填充生成的   目录中包含必要的文件:

     

〜/ src / mupdf $ make generate构建和调试

     

切换到platform / android目录并编辑本地   属性配置文件。

     

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

另一个注意事项,在复制local.properties之后,我添加了这一行:

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

其中D:\ adt-bundle-windows-x86 \ sdk是我的android sdk所在的位置。

我从MuPDF网站上获得了上述内容。 在构建源代码时,我得到了这个: Possible error while building

之后,我将代码从mupdf / source / platform / android /导入到我的eclipse工作区。项目构建正常,pdf选择器打开它应该;但是当我选择一些pdf时,它会崩溃并出现以下错误:

  

06-15 10:34:43.267:E / AndroidRuntime(16870):致命异常:主要   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):引起:java.lang.UnsatisfiedLinkError:   无法加载mupdf:findLibrary返回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)

这里出了什么问题? 我正在使用cygwin,我正在运行Windows 7。

我计划将mupdf用作渲染pdfs的库

1 个答案:

答案 0 :(得分:1)

您的logcat清楚地显示它是“由以下引起:java.lang.UnsatisfiedLinkError:无法加载mupdf:”,即失败,因为它无法加载“libmupdf.so”库。

确保您已正确执行the MuPDF documentation page上的所有步骤。确保所有命令都成功运行而不会出现任何错误。查看终端(命令提示符)屏幕截图,似乎“”make“命令失败。

在ndk-build步骤之后,必须生成“libmupdf.so”。确保它在Android-Project-Folder / libs / armeabi-v7a /