Runtime exception error in android studio logcat. It is showing two errors at the same time: Runtime exception and NullPointerException

This question already has an answer here:

  • What is a NullPointerException, and how do I fix it?

    12 answers

I am creating a simple static application in android studio. When I tried to run the application using USB debugging option, It crashed and showed two errors in logcat:
Screenshot of logcat

I am new to android studio and it is my first project, please help me in debugging this error.
Here is the screenshot for the MainActivity Java code where the error is supposed to be:
JAVA MainActivity

It is only one error. You have an NPE in MainActivity line 39, that error has caused the RuntimeException. It looks like button is null for some reason. Maybe your button ( is not actually declared in R.layout.activity_main.