Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference

tv8=(TextView)findViewById(R.id.editText4);
tv9=(TextView)findViewById(R.id.editText5);
tv10=(TextView)findViewById(R.id.editText6);

Change these to:

tv8=(TextView)findViewById(R.id.textView4);
tv9=(TextView)findViewById(R.id.textView5);
tv10=(TextView)findViewById(R.id.textView6);

You just used the wrong id's.


If you have seen following type of Null Pointer Exception in your program at run time

java.lang.NullPointerException: *Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)'* on a null object reference
        at MainActivity.onCreate(MainActivity.java:17)

While your Application will crash immediately then check for any error in TextView in Layout file and also match the view id in respective Java/Kotlin file where you are accessing this TextView.

    android:id="@+id/text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Hello World!"