导出 mupdf 和 android studio 0.5.4 [英] export mupdf and android studio 0.5.4

查看:21
本文介绍了导出 mupdf 和 android studio 0.5.4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先:我想在我的 android 应用程序中查看 pdf 文件.我搜索并分析并决定使用 mupdf首先,我使用本指南来构建演示项目它在 eclipse 中工作正常.但我需要在 Android Studio 中运行它.我尝试从 Eclipse 导出为 gradle 项目并导入到 Android Studio.文件资源管理器可以工作,但是当我打开 pdf 时出现错误:

 java.lang.ExceptionInInitializerError在 com.artifex.mupdfdemo.MuPDFActivity.openFile(MuPDFActivity.java:213)在 com.artifex.mupdfdemo.MuPDFActivity.onCreate(MuPDFActivity.java:309)在 android.app.Activity.performCreate(Activity.java:5008)...引起:java.lang.UnsatisfiedLinkError:无法加载mupdf:findLibrary返回空在 java.lang.Runtime.loadLibrary(Runtime.java:365)在 java.lang.System.loadLibrary(System.java:535)在 com.artifex.mupdfdemo.MuPDFCore.<clinit>(MuPDFCore.java:14)在 com.artifex.mupdfdemo.MuPDFActivity.openFile(MuPDFActivity.java:213)在 com.artifex.mupdfdemo.MuPDFActivity.onCreate(MuPDFActivity.java:309)

我尝试只导入项目而不在 Eclipse 中进行转换,但是当我运行应用程序时,出现错误:

错误:任务:app:compileDebugNdk"的执行失败.

<块引用>

com.android.ide.common.internal.LoggedErrorException:无法运行命令: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错误代码:2输出:make.exe: * 无规则生成目标 C:\mupdf\platform\android\app\build\ndk\debug\obj/local/armeabi-v7a/objs/mupdf/C_\mupdf\platform\android\app\src\main\jni',需要C:\mupdf\platform\android\app\build\ndk\debug\obj/local/armeabi-v7a/objs/mupdf/C_\mupdf\platform\android\app\src\main\jni\mupdf.o'.停止.

  1. 如何将 mupdf 库添加到 Android Studio 和我的项目中?我将感谢任何链接,示例.任何可以提供帮助的.
  2. 如何将带有本机代码的项目导入到 Android Studio?我绝对是 NDK 的菜鸟,害怕我需要阅读大量的教程和书籍才能导入项目.

解决方案

您收到的错误似乎表明您的 .so 文件没有正确集成到您的 APK 中.您可以通过解压 APK 并查看 lib/armeabi-v7alib/x86

如果jni/文件夹下只有一个.c或.cpp源文件,可能是这个No rule to make target错误的原因,有Windows 上的已知错误:https://code.google.com/p/android/issues/detail?id=66937

如果您在使用 Android Studio 和 NDK 时遇到其他问题,我在这里写了一篇可以帮助您的文章:http://ph0b.com/android-studio-gradle-and-ndk-integration/

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 byC:\mupdf\platform\android\app\build\ndk\debug\obj/local/armeabi-v7a/objs/mupdf/C_\mupdf\platform\android\app\src\main\jni\mupdf.o'. Stop.

  1. How to add mupdf library to Android Studio and in my project? I will appreciate any link, examples. Any that could help.
  2. 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.

解决方案

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/

这篇关于导出 mupdf 和 android studio 0.5.4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆