tags: Android Run error collection station
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.lwm.myapplication/com.lwm.myapplication.MainActivity}
Java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.

The exception means: you need to use a theme.appcompat theme (or descendant) with this activity. Why this happens is because Activity inherits AppCompatActivity, as follows:
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
But the appTheme I use is the theme of the normal Activity, so an error will be reported. The error message requires us to use the theme (or descendant) that inherits theme.appcompat.
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
The first method: change the theme so that the theme inherits fromtheme.appcompat.xxx
This is an AppTheme that is automatically created when we create a new project. Note that it is inherited from Theme.AppCompat.xxx
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
The second method: change the inheritance of the class from AppCompatActivity to Activity or FragmentActivity.
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
Reprinted:
When I implement a message round-trip, I get an APP flashback: Print the log out: The specific content is: The problem is the LooperTextView: Add com.ghl.intelligence in front of the LooperTextView to...
Error report details: Process: com.serenegiant.usbcameratest, PID: 4409 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.serenegiant.usbcameratest/com.serenegiant.usbcameratest.M...
Android Studio reports the following error: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xx.xx/com.xx.xx.MainActivity}: android.view.InflateException: Binary XML file line #:...
Android Studio reports the following error: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xx.xx/com.xx.xx}: android.view.InflateException: Binary XML file line #: Error inflat...
Error message: Reason 1: The error of xxx, if it is R.layout.main, it should be the tag usage error in the main.xml file. The most common error that the compiler will not prompt is the confusion betwe...
Report error message: wrong reason: Actionbar is an empty pointer in the code. Solution: Check if the THEME of the AndroidManifest.xml file is: Change it to:...
Virtual machine error display: The project collapsed as soon as it runs. The error prompt given by the compiler: It can be determined that it is the problem of the XML file Focus on observing the caus...
I encountered this runtime exception when writing the demo. Generally, this is because the package name or the Activity name is wrong. Refer to this blog Problems with wrong names After trying these m...
problem: Prepare to pop up a dialog box in the onReceive method, and report the above error, and later add a line of code to get it done! Add before alertDialog.show(): Reason: Since it is started in ...
The result of calling startActivity in Android leads to: check the Internet, summarized as follows: The first case: java.lang.RuntimeException: Unable to start activity ComponentInfo{xxx}: java.lang.N...