Android studio: The problem of crashing when opening the application


Problems encountered during the development of Android applications

Problem Description

After developing (or testing, such a simple program may be difficult to call development) an Android, when debugging the developed app in Android studio, the editor does not prompt an error, and there is no problem downloading in the virtual machine, but The app crashes as soon as it is opened. When you open it again, the words app keeps stopping will appear.

Analyze the reasons

I have read a lot of articles, usually about XML correspondence, mainifest registration, etc. However, after investigating these reasons, I found that there are no problems with them. So what is the reason?
After carefully looking at the debugger logcat of Android studio
Insert image description here
the problem was locked in the loading of the page, because the application was successfully installed and Logcat does not report the problem of the written page, indicating that it is not for other reasons. It is mostly caused by the software not calling the pages in a reasonable order. This adjustment is in the mainifest
Insert image description here
You can see that the android:name="..." in <activity < /activity> is the required main page. It turns out that this is the "MainActivity" automatically generated when creating the project, which is the project structure java package. MainActivity.kt, after modifying it to the mainactivity written by myself, I should be able to modify the main page, but there will still be a crash problem after running, so there should be no problem, but why is it still crashing? ?

Solution

Then I probably know that the problem is caused by page loading (possibly), so I won’t stop doing it and simply delete MainActivity.kt, which is the one automatically generated when creating the project mentioned above. file, and also delete the content about the file in the mainifest, and run it again
Insert image description here
. It can be used normally. Although the real reason is not very clear, it is probably the reason mentioned above, at least it is related. A lot

参考文章
linkhttp://t.csdnimg.cn/Rj5AD
linkhttp://t.csdnimg.cn/br3po

Supongo que te gusta

Origin blog.csdn.net/m0_72471315/article/details/134227722
Recomendado
Clasificación