我的问题是,我如何正确地使这个项目成为一个图书馆项目并从另一个项目运行它?
我尝试将它标记为一个库项目并将其添加到我的主项目的构建路径中,但我得到了
请注意,我使用的是Mupdf-1.5(目前最新的)
ExpressionInitializerError,could not load library,FindLibrary
Returned NUll errors
那我该怎么办?
我的库名是libmupdf.
注意,我是android-ndk的新手.我的主项目中没有任何jni文件夹,只在库项目中.
这是完整的错误.
06-16 17:51:27.680: E/AndroidRuntime(5673): FATAL EXCEPTION: main
06-16 17:51:27.680: E/AndroidRuntime(5673):
java.lang.ExceptionInInitializerError 06-16 17:51:27.680:
E/AndroidRuntime(5673): at java.lang.Class.newInstanceImpl(Native
Method) 06-16 17:51:27.680: E/AndroidRuntime(5673): at
java.lang.Class.newInstance(Class.java:1319) 06-16 17:51:27.680:
E/AndroidRuntime(5673): at
android.app.Instrumentation.newActivity(Instrumentation.java:1025)
06-16 17:51:27.680: E/AndroidRuntime(5673): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
06-16 17:51:27.680: E/AndroidRuntime(5673): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
06-16 17:51:27.680: E/AndroidRuntime(5673): at
android.app.ActivityThread.access$600(ActivityThread.java:123) 06-16
17:51:27.680: E/AndroidRuntime(5673): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
06-16 17:51:27.680: E/AndroidRuntime(5673): at
android.os.Handler.dispatchMessage(Handler.java:99) 06-16
17:51:27.680: E/AndroidRuntime(5673): at
android.os.Looper.loop(Looper.java:137) 06-16 17:51:27.680:
E/AndroidRuntime(5673): at
android.app.ActivityThread.main(ActivityThread.java:4424) 06-16
17:51:27.680: E/AndroidRuntime(5673): at
java.lang.reflect.Method.invokeNative(Native Method) 06-16
17:51:27.680: E/AndroidRuntime(5673): at
java.lang.reflect.Method.invoke(Method.java:511) 06-16 17:51:27.680:
E/AndroidRuntime(5673): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:825)
06-16 17:51:27.680: E/AndroidRuntime(5673): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:592) 06-16
17:51:27.680: E/AndroidRuntime(5673): at
dalvik.system.NativeStart.main(Native Method) 06-16 17:51:27.680:
E/AndroidRuntime(5673): Caused by: java.lang.UnsatisfiedLinkError:
Couldn’t load libmupdf: findLibrary returned null 06-16 17:51:27.680:
E/AndroidRuntime(5673): at
java.lang.Runtime.loadLibrary(Runtime.java:365) 06-16 17:51:27.680:
E/AndroidRuntime(5673): at
java.lang.System.loadLibrary(System.java:535) 06-16 17:51:27.680:
E/AndroidRuntime(5673): at
com.mainpackage.MainActivity.(MainActivity.java:44)
请帮助我,它杀了我几天.提前致谢.
这是我的Android.mk:
LOCAL_PATH := $(call my-dir) TOP_LOCAL_PATH := $(LOCAL_PATH) MUPDF_ROOT := ../.. ifdef NDK_PROFILER include android-ndk-profiler.mk endif include $(TOP_LOCAL_PATH)/Core.mk include $(TOP_LOCAL_PATH)/ThirdParty.mk include $(CLEAR_VARS) LOCAL_C_INCLUDES := \ jni/andprof \ $(MUPDF_ROOT)/include \ $(MUPDF_ROOT)/source/fitz \ $(MUPDF_ROOT)/source/pdf LOCAL_CFLAGS := LOCAL_MODULE := mupdf LOCAL_SRC_FILES := mupdf.c LOCAL_STATIC_LIBRARIES := mupdfcore mupdfthirdparty ifdef NDK_PROFILER LOCAL_CFLAGS += -pg -DNDK_PROFILER LOCAL_STATIC_LIBRARIES += andprof else endif LOCAL_LDLIBS := -lm -llog -ljnigraphics ifdef SSL_BUILD LOCAL_LDLIBS += -L$(MUPDF_ROOT)/thirdparty/openssl/android -lcrypto -lssl endif include $(BUILD_SHARED_LIBRARY)
这是我的项目的快照.有两个突出显示的项目,它们是被讨论的项目,ChoosePDFActivity是图书馆项目.
,
好的,这样的事情对我的情况有用:
是否有可能在我的最终构建中包含一个Whole项目?我只需要从我的主项目中传递一个intent,而其他所有内容都将由ChoosePdf …项目处理.
附:
我注意到只有armeabi-v7a.那么,有没有办法为其他架构构建mupdf
编辑
对于那些想要在Android中进行PDF渲染的人来说,Android L(终于)获得了使本机pdf渲染成为可能的api.
解决方法
https://stackoverflow.com/a/2957386/892714
ndk构建系统(遗憾的是)不会在没有动态库使用的情况下创建静态库.然后,您只需从obj / local / armeabi-v7a中获取静态库.