Table of contents
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
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
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
. 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