0

Thanks to this site, my app is coming along nicely. However, it crashes when switching to a new activity I just created. There are 6 activities where the user answers questions, on Activity #5 in the sequence, the app crashes when I press the continue button. I get the standard "Unfortunately, App has stopped." When I press OK, the app closes and re-opens, and I am taken back to Activity #4, which retains the user input which I saved to SharedPreferences.

Log from the time I press the continue button:

02-27 08:42:54.231 7307-7307/com.health.hermes D/ViewRootImpl: MSG_RESIZED: ci=Rect(0, 96 - 0, 0) vi=Rect(0, 96 - 0, 0) or=1
02-27 08:42:54.541 7307-7307/com.health.hermes D/ViewRootImpl: ViewPostImeInputStage processPointer 0
02-27 08:42:54.611 7307-7307/com.health.hermes D/ViewRootImpl: ViewPostImeInputStage processPointer 1
02-27 08:42:54.621 7307-7307/com.health.hermes I/Timeline: Timeline: Activity_launch_request id:com.health.hermes time:1000022770
02-27 08:42:54.681 7307-7307/com.health.hermes D/TextView: setTypeface with style : 0
02-27 08:42:54.681 7307-7307/com.health.hermes D/TextView: setTypeface with style : 0
02-27 08:42:54.691 7307-7307/com.health.hermes D/AndroidRuntime: Shutting down VM
02-27 08:42:54.691 7307-7307/com.health.hermes E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.health.hermes, PID: 7307
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.health.hermes/com.health.hermes.KiPercentActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.EditText.setFilters(android.text.InputFilter[])' on a null object reference
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3253)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349)
        at android.app.ActivityThread.access$1100(ActivityThread.java:221)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:158)
        at android.app.ActivityThread.main(ActivityThread.java:7225)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.EditText.setFilters(android.text.InputFilter[])' on a null object reference
        at com.health.hermes.KiPercentActivity.onCreate(KiPercentActivity.java:30)
        at android.app.Activity.performCreate(Activity.java:6876)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349) 
        at android.app.ActivityThread.access$1100(ActivityThread.java:221) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:158) 
        at android.app.ActivityThread.main(ActivityThread.java:7225) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 

If you see the cause, kindly point out how I can better understand the logcat so I can start diagnosing myself. Thank you!

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
jon.bray.eth
  • 527
  • 6
  • 13
  • 1
    it's a null pointer exception. Check this answer [link](https://stackoverflow.com/questions/218384/what-is-a-nullpointerexception-and-how-do-i-fix-it) – abhndv Feb 27 '19 at 13:45
  • Provide your code please, where you store it and when you read it thanks – Skizo-ozᴉʞS ツ Feb 27 '19 at 13:46
  • @newton_cr7 Thank you! I was setting an input filter on the TextView instead of EditText, and did not reference my button in the activity.class. After reading through the log, I see where it happened. – jon.bray.eth Feb 27 '19 at 13:51
  • next time read the log first, then post question – Tim Feb 27 '19 at 13:52
  • @Ricardo Yes. That answer is very definitive and covered just about everything that I needed to know. – jon.bray.eth Feb 27 '19 at 13:52
  • @TimCastelijns I have never had to read a log before, and am not positive I would have known what to look for. Thank you to everyone else for helping me understand, I have a better idea of how to read the log after the help here. – jon.bray.eth Feb 27 '19 at 13:53

1 Answers1

0

Here is your answer.

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.EditText.setFilters(android.text.InputFilter[])' on a null object reference at com.health.hermes.KiPercentActivity.onCreate(KiPercentActivity.java:30) at android.app.Activity.performCreate(Activity.java:6876) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135)

your EditText is null that's why is happening.

UPDATE Multiple items ended up being null, thank you for taking the time to look into my log. Answer covered already here:

What is a NullPointerException, and how do I fix it?

jon.bray.eth
  • 527
  • 6
  • 13