Android 的 MuPDF 编译在 generateJsonModelRelease 中失败

MuPDF compile for Android fails in generateJsonModelRelease

执行 [1] make 中的步骤在任务 :jni:generateJsonModelRelease 期间失败,争论缺少体系结构定义。我已经将 APP_ABI := all 添加到 ${PROJECT_HOME}/jni/Application.mk 但没有成功。

$ make
ANDROID_HOME=/Users/paddel10/Library/Android/sdk ./gradlew assembleDebug
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
...
:jni:generateJsonModelRelease
/Users/paddel10/Library/Android/sdk/ndk-bundle/build/core/init.mk:537: *** Android NDK: Aborting...    .  Stop.
/Users/paddel10/Library/Android/sdk/ndk-bundle/build/core/init.mk:537: *** Android NDK: Aborting...    .  Stop.
/Users/paddel10/Library/Android/sdk/ndk-bundle/build/core/init.mk:537: *** Android NDK: Aborting...    .  Stop.
:jni:generateJsonModelRelease FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':jni:generateJsonModelRelease'.
> Build command failed.
  Error while executing process /Users/paddel10/Library/Android/sdk/ndk-bundle/ndk-build with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=/Users/paddel10/Downloads/mupdf-android-viewer-mini/jni/libmupdf/platform/java/Android.mk APP_ABI=armeabi NDK_ALL_ABIS=armeabi NDK_DEBUG=0 APP_PLATFORM=android-16 NDK_OUT=/Users/paddel10/Downloads/mupdf-android-viewer-mini/jni/build/intermediates/ndkBuild/release/obj NDK_LIBS_OUT=/Users/paddel10/Downloads/mupdf-android-viewer-mini/jni/build/intermediates/ndkBuild/release/lib -j4 APP_SHORT_COMMANDS=false LOCAL_SHORT_COMMANDS=false -B -n}
  Android NDK: INTERNAL ERROR: The armeabi ABI should have exactly one architecture definitions. Found: ''
  /Users/paddel10/Library/Android/sdk/ndk-bundle/build/core/init.mk:537: *** Android NDK: Aborting...    .  Stop.
  make[1]: Entering directory `/Users/paddel10/Downloads/mupdf-android-viewer-mini/jni'
  make[1]: Leaving directory `/Users/paddel10/Downloads/mupdf-android-viewer-mini/jni'
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 1.06 secs
make: *** [assembleDebug] Error 1
$

$ ndk-build --version
GNU Make 3.81

[1] https://www.mupdf.com/docs/android-build-viewer.html

你可以使用 mupdf-aar

无需安装NDK

我终于设法编译了源代码。为此,我不得不在 jni/build.gradle 中调整 属性 ndk.abiFilters。此外,似乎 armeabi 不再受支持。

vi jni/build.gradle
android {
  ...
  defaultConfig {
    ...
    ndk.abiFilters 'arm64-v8a'
  }
  ...
}

# don't forget to generate the sources in the jni directory
cd jni
make generate

# compile
cd ..
make