"Unable to start activity ComponentInfo{com.example/com.artifex.mupdfdemo.MuPDFActivity}: java.lang.NullPointerException"

StackOverflow https://stackoverflow.com/questions/17524915

  •  02-06-2022
  •  | 
  •  

Question

I wanted to add MuPDF class into my android project. I do all stuff in the link successfully. And I added all files into my application from /mupdf-source/android/.

After I added MuPDFActivity to my Manifest.xml.

<activity 
    android:name="com.artifex.mupdfdemo.MuPDFActivity"
    android:screenOrientation="landscape">
</activity>

To open MuPDFActivity I use this code.

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);

But when I run the code I get these errors from the 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

What can be the problem? How can I solve it?

Was it helpful?

Solution

Caused by: java.lang.NullPointerException

com.artifex.mupdfdemo.MuPDFActivity.makeButtonsView(MuPDFActivity.java:835)

A button has something what is missing for him. Check the mupdfdemo what need for that button for more info

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top