【问题标题】:Compiled MuPDF library integration in android projectandroid项目中编译的MuPDF库集成
【发布时间】:2026-01-18 17:30:01
【问题描述】:

我已经编译了 mupdf 库,但是当我将它集成到我现有的 android 项目中以呈现 PDF 时,它给了我以下错误:

java.lang.ExceptionInInitializerError

我已按照以下步骤进行集成:

这里解释了步骤: http://pastebin.com/YzHUhzE7

当我在 mupdf 测试项目中更改包名称时,本机代码会被修改,并且会出现上述到期。因此,如果有人知道如何将 MuPDF 集成到我的项目中。

【问题讨论】:

    标签: pdf-rendering


    【解决方案1】:

    我终于把编译好的mupdf库集成到我的项目中了。

    我遵循以下步骤: 将库导入我的项目后,在 jni 上运行 ndk-build。它将建立图书馆。 现在 ExpetionInitializationError 已解决。 现在应用程序正在设备上运行。

    【讨论】:

    • 只有一个问题,你让它兼容各种架构吗?
    • 是的,我通过在编译时将 api 级别设置为 3 使其与所有架构兼容
    • 你好,你能提供一个压缩库的工作副本吗?我真的很感激。
    【解决方案2】:

    你可以在这个链接http://www.chinabtp.com/android-pdf-viewer-library-or-mupdf-library-tutorials/找到答案

    说明如下:

    Building a MuPDF lib on windows with Cygwin and android-ndk
    
    Download MuPDF 1.3 Source from https://code.google.com/p/mupdf/downloads/list unzip to folder c:/mupdf-1.3-source
    
    Install Cygwin: Download and run Run setup-x86.exe from http://cygwin.com/install.html when installing cygwin, make sure you selected make packages and C++ compilers
    
    Make generate. open cygwin terminal, run
    
    cd /cygdrive/
    cd c/mupdf-1.3-source
    make generate
    
    Install android-ndk: download android-ndk-r9d-windows-x86.zip and unzip it to
    
    c:/android-ndk-r9d
    
    Build mupdf lib: on windows cmd console:
    
        preparation:
    
        cd c:/mupdf-1.3-source/platform/android
        copy local.properties.sample local.properties
    
        edit local.properties, uncomment
    
        #sdk.dir=C:\\Program Files (x86)\\Android\\android-sdk
    
        and change to
    
        sdk.dir=REAL andforid-sdk Folder
    
        build: while still on c:/mupdf-1.3-source/platform/android, run:
    
        /android-ndk-r9d/ndk-build
    
        Upon the completion of the build, a folder named libs will be created under
    
        c:/mupdf-1.3-source/platform/android
    
    Create android apk. Open eclipse, create a new android project from existing code, browse to c:/mupdf-1.3-source/platform/android, now you can create a mupdf apk.
    

    【讨论】: