我想将MuPDF类添加到我的android项目中。我成功完成了in the link的所有工作。然后将所有文件从/mupdf-source/android/
添加到我的应用程序中。
在将MuPDFActivity添加到Manifest.xml之后。
<activity
android:name="com.artifex.mupdfdemo.MuPDFActivity"
android:screenOrientation="landscape">
</activity>
要打开MuPDFActivity,请使用以下代码。
Uri uri = Uri.parse("/storage/sdcard0/file.pdf");
Intent intent = new Intent(CarDetail.this,MuPDFActivity.class);
intent.setAction(Intent.ACTION_VIEW);
intent.setData(uri);
startActivity(intent);
但是,当我运行代码时,我从LogCat中得到了这些错误
07-08 13:52:03.137: E/AndroidRuntime(16925): FATAL EXCEPTION: main
07-08 13:52:03.137: E/AndroidRuntime(16925): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.artechin.mbtkatalog/com.artifex.mupdfdemo.MuPDFActivity}: java.lang.NullPointerException
07-08 13:52:03.137: E/AndroidRuntime(16925): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2110)
07-08 13:52:03.137: E/AndroidRuntime(16925): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
07-08 13:52:03.137: E/AndroidRuntime(16925): at android.app.ActivityThread.access$700(ActivityThread.java:140)
07-08 13:52:03.137: E/AndroidRuntime(16925): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237)
07-08 13:52:03.137: E/AndroidRuntime(16925): at android.os.Handler.dispatchMessage(Handler.java:99)
07-08 13:52:03.137: E/AndroidRuntime(16925): at android.os.Looper.loop(Looper.java:137)
07-08 13:52:03.137: E/AndroidRuntime(16925): at android.app.ActivityThread.main(ActivityThread.java:4921)
07-08 13:52:03.137: E/AndroidRuntime(16925): at java.lang.reflect.Method.invokeNative(Native Method)
07-08 13:52:03.137: E/AndroidRuntime(16925): at java.lang.reflect.Method.invoke(Method.java:511)
07-08 13:52:03.137: E/AndroidRuntime(16925): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
07-08 13:52:03.137: E/AndroidRuntime(16925): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
07-08 13:52:03.137: E/AndroidRuntime(16925): at dalvik.system.NativeStart.main(Native Method)
07-08 13:52:03.137: E/AndroidRuntime(16925): Caused by: java.lang.NullPointerException
07-08 13:52:03.137: E/AndroidRuntime(16925): at com.artifex.mupdfdemo.MuPDFActivity.makeButtonsView(MuPDFActivity.java:835)
07-08 13:52:03.137: E/AndroidRuntime(16925): at com.artifex.mupdfdemo.MuPDFActivity.createUI(MuPDFActivity.java:416)
07-08 13:52:03.137: E/AndroidRuntime(16925): at com.artifex.mupdfdemo.MuPDFActivity.onCreate(MuPDFActivity.java:337)
07-08 13:52:03.137: E/AndroidRuntime(16925): at android.app.Activity.performCreate(Activity.java:5188)
07-08 13:52:03.137: E/AndroidRuntime(16925): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
07-08 13:52:03.137: E/AndroidRuntime(16925): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2074)
07-08 13:52:03.137: E/AndroidRuntime(16925): ... 11 more
可能是什么问题?我该如何解决?
最佳答案
Caused by: java.lang.NullPointerException
com.artifex.mupdfdemo.MuPDFActivity.makeButtonsView(MuPDFActivity.java:835)
按钮有他缺少的东西。
检查mupdfdemo该按钮需要什么以获取更多信息