• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

java.lang.NullPointerException: Attempt to invoke virtual method error

Randy_Gold

Lurker
I am getting this error whenever I try running my app. The app crashes when I press the sign up button. I am using android studio version 3.6.3 and my platform is windows 10. Here is the error screen:

'code'
java.lang.NullPointerException: Attempt to invoke virtual method 'android.text.Editable android.widget.EditText.getText()' on a null object reference
at com.ismail.financemanagement.RegisterActivity$1.onClick(RegisterActivity.java:52)
at android.view.View.performClick(View.java:7865)
at android.widget.TextView.performClick(TextView.java:14958)
at android.view.View.performClickInternal(View.java:7838)
at android.view.View.access$3600(View.java:886)
at android.view.View$PerformClick.run(View.java:29362)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:8016)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1076)

'code'
 

Attachments

Why you need to initialize your xml twice?

Since you already have setContentView(R.layout.activity_register);, so just remove this line:

Java:
 View mView = getLayoutInflater().inflate(R.layout.activity_register, null);
 
Back
Top Bottom