When running the Android program, "××× has stopped running" appears

When running the Android program, "××× has stopped running" appears, and after clicking "Reopen the application", it prompts "××× has stopped running repeatedly",

 

 

I found that there is such a line in Logcat: "Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.view.View.findViewById(int)' on a null object reference at
        com.example .helloworld.MainActivity.onCreate( MainActivity.java:27 )"

Click the blue font to jump to the problematic part of the code. It turned out to be a small careless problem: the equal sign was wrongly written as a dot

 

 Change it to = and it will run successfully.

The search found that the information prompted is a null pointer exception, which is related to the id defined in the XML file.

This is just my problem, hope it can help you.

Guess you like

Origin blog.csdn.net/qq_51387458/article/details/130684373