1. Are you ready for the Galaxy S20? Here is everything we know so far!

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

Discussion in 'Android Development' started by Randy_Gold, May 28, 2020.

  1. Randy_Gold

    Randy_Gold Lurker
    Thread Starter

    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'
     

    Attached Files:




    1. Download the Forums for Android™ app!


      Download

       
  2. wseng92

    wseng92 Android Enthusiast

    Why you need to initialize your xml twice?

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

    Code (Java):
    1.  View mView = getLayoutInflater().inflate(R.layout.activity_register, null);
     
    MrJavi likes this.
Loading...

Share This Page

Loading...