问题
First: I want to view pdf files in my android app. I googled and analyzed and decided to use mupdf For a start I use this guide to build demo project and it's work fine in eclipse. But I need to run it in Android studio. I try to export from eclipse as gradle project and import to Android Studio. File explorer work, but when I opened pdf I get error:
java.lang.ExceptionInInitializerError
at com.artifex.mupdfdemo.MuPDFActivity.openFile(MuPDFActivity.java:213)
at com.artifex.mupdfdemo.MuPDFActivity.onCreate(MuPDFActivity.java:309)
at android.app.Activity.performCreate(Activity.java:5008)
...
Caused by: java.lang.UnsatisfiedLinkError: Couldn't load mupdf: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:365)
at java.lang.System.loadLibrary(System.java:535)
at com.artifex.mupdfdemo.MuPDFCore.<clinit>(MuPDFCore.java:14)
at com.artifex.mupdfdemo.MuPDFActivity.openFile(MuPDFActivity.java:213)
at com.artifex.mupdfdemo.MuPDFActivity.onCreate(MuPDFActivity.java:309)
I try to just import project without convert it in Eclipse, but when I run application, I get error:
Error:Execution failed for task ':app:compileDebugNdk'.
com.android.ide.common.internal.LoggedErrorException: Failed to run command: C:\SpeedBoots\android-ndk-r9d\ndk-build.cmd NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=C:\mupdf\platform\android\app\build\ndk\debug\Android.mk APP_PLATFORM=android-19 NDK_OUT=C:\mupdf\platform\android\app\build\ndk\debug\obj NDK_LIBS_OUT=C:\mupdf\platform\android\app\build\ndk\debug\lib APP_ABI=all Error Code: 2 Output: make.exe: * No rule to make target
C:\mupdf\platform\android\app\build\ndk\debug\obj/local/armeabi-v7a/objs/mupdf/C_\mupdf\platform\android\app\src\main\jni', needed by
C:\mupdf\platform\android\app\build\ndk\debug\obj/local/armeabi-v7a/objs/mupdf/C_\mupdf\platform\android\app\src\main\jni\mupdf.o'. Stop.
- How to add mupdf library to Android Studio and in my project? I will appreciate any link, examples. Any that could help.
- How to import projects with native code to Android Studio? I'm absolute noob in NDK and scare that I need to read tons of tutorial and books for just import project.
回答1:
the errors you are getting seem to indicate that your .so files aren't getting integrated correctly into your APK. You can check that by unzipping your APK and looking inside lib/armeabi-v7a
, lib/x86
, etc
If there is only one .c or .cpp source file under jni/
folder, that may be the cause of this No rule to make target
error, there is known bug on Windows: https://code.google.com/p/android/issues/detail?id=66937
If you run into other troubles with Android Studio and the NDK, I've made an article that may help you here: http://ph0b.com/android-studio-gradle-and-ndk-integration/
来源:https://stackoverflow.com/questions/23042102/export-mupdf-and-android-studio-0-5-4