0

I'm stuck on this error, app stops immediately i click register. I need to correct register_activity.java but there are no errors

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
                                                                                           at ke.co.myresolv.www.myresolvkenyalogin.activities.RegisterActivity.initListeners(RegisterActivity.java:79)
                                                                                           at ke.co.myresolv.www.myresolvkenyalogin.activities.RegisterActivity.onCreate(RegisterActivity.java:52)
                                                                                           at android.app.Activity.performCreate(Activity.java:6679)
                                                                                           at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
                                                                                           at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
                                                                                           at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726) 
                                                                                           at android.app.ActivityThread.-wrap12(ActivityThread.java) 
                                                                                           at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477) 
                                                                                           at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                           at android.os.Looper.loop(Looper.java:154) 
                                                                                           at android.app.ActivityThread.main(ActivityThread.java:6119) 
                                                                                           at java.lang.reflect.Method.invoke(Native Method) 
                                                                                           at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) 
                                                                                           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
UmarZaii
  • 1,355
  • 1
  • 17
  • 26
  • Possible duplicate of [What is a NullPointerException, and how do I fix it?](https://stackoverflow.com/questions/218384/what-is-a-nullpointerexception-and-how-do-i-fix-it) – Srikar Reddy Jul 28 '17 at 15:19
  • There are generally two types of errors: syntax errors and logic errors. You have a logic error. This is something that android studio doesnt pick up on. why? because your syntax is properly coded.... but your logic is wrong and is returning a null. showing us the error log does nothing to help you, sir. perhaps show us your code? – letsCode Jul 28 '17 at 15:23
  • please post your activity code and xml – Sangram Haladkar Jul 28 '17 at 15:25
  • Kindly edit your question, and include your code for `register` click event – boop_the_snoot Jul 28 '17 at 15:32

1 Answers1

1

make sure that the button has been correctly assigned with correct id of the corresponding xml. i.e. Button myRegisterBtn = (Button)findViewById(R.id.myRegisterBtn);//make sure the id within findViewById is located in the xml you inflated in your activity.

HaroldSer
  • 2,025
  • 2
  • 12
  • 23