0

I have edited the NullPointerException present in MainActivity and have exported (cut, copy and paste)them into another class. But my Logcat shows an error in MainActivity. After modifying for `NullPointerException this is my code:

    if(value!=null && value.length()>0){
      try{
        length = Integer.parseInt(value);

      }
      catch (NullPointerException e){
        length=0;
      }
    }

My logcat shows:

java.lang.NullPointerException: Attempt to invoke virtual method 'android.text.Editable 
        android.widget.EditText.getText()' on a null object reference
        at com.example.caddrawingtool.MainActivity.drawline(MainActivity.java:114)
        at com.example.caddrawingtool.MainActivity.onOptionsItemSelected(MainActivity.java:57)
        at android.app.Activity.onMenuItemSelected(Activity.java:4137)
        at androidx.fragment.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:384)
        at androidx.appcompat.app.AppCompatActivity.onMenuItemSelected(AppCompatActivity.java:228)
      androidx.appcompat.view.WindowCallbackWrapper.onMenuItemSelected(WindowCallbackWrapper.java:109)

when my MainActivity has only 109 lines. I am confused.

Gayathri
  • 69
  • 8
  • Are you building with R8/ProGuard enabled (`minifyEnabled true`)? If so, maybe try turning that off and rebuild. If not, maybe try cleaning and doing a full rebuild. – Michael Mar 08 '21 at 14:49

1 Answers1

0

Simple once click on Build (On top) and then look for clean project