Simple steps: Solve the error "xxx (project name) has stopped" in Android studio

Problem Description:

When I was writing a project code for an address book, when I used Android studio to run the project, I found that the efficiency of the virtual machine was much slower, and after running, the expected effect of our project did not appear, but "xxx (project name) has stopped" error. Clicking Open app again has no effect either.

 watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA6JuH5b2i5YiB5omL,size_15,color_FFFFFF,t_70,g_se,x_16


solution:

the first case

1. If this error occurs, the probability is that the AndroidManifest.xml under the manifests package has not been modified. When the software is running, it will run the default configuration file first. You can first check whether the java class you write is consistent with the name of the activity in AndroidManifest.xml. From the figure below, you can see that the activity in my AndroidManifest.xml is still the default MainActivity class after creating a new project, without modification.

watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA6JuH5b2i5YiB5omL,size_10,color_FFFFFF,t_70,g_se,x_16

 2. We only need to change android:name=".MainActivity" to our own ".ContactActivity", then put the mouse on android:name=".ContactActivity", when an error occurs, click it and select, modify Contents in tools.

<1>

<activity
            android:name=".MainActivity"
            android:exported="true"
            tools:ignore="Instantiatable">
</activity>

<2>

watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA6JuH5b2i5YiB5omL,size_18,color_FFFFFF,t_70,g_se,x_16

<3>

<activity
            android:name=".ContactActivity"
            android:exported="true"
            tools:ignore="MissingClass">
</activity>

 3. After re-running, it can be found that the project effect has been successfully achieved. Such problems come down to not being careful enough when we write the code, but they are relatively easy to solve.

 watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA6JuH5b2i5YiB5omL,size_10,color_FFFFFF,t_70,g_se,x_16


the second case

The second case may be that the package name is inconsistent. You can see from the figure below that the package name prefix is ​​cn.  And the package name I wrote is prefixed with com.

Therefore, an error is reported. This situation is also because we are not careful enough when writing the code, and it is easy to solve it by searching and modifying it again.


thanks for watching! ! !

Sanlian is the biggest support! ! !

Guess you like

Origin blog.csdn.net/qq_56017400/article/details/124185281