Caused By: Java.lang.illegalstateexception: You Need To Use A Theme-appcompat

Caused By: Java.lang.illegalstateexception: You Need To Use A Theme-appcompat
  1. Caused By Java.lang.illegalstateexception You Need To Use A Theme.appcompat Theme

Caused By Java.lang.illegalstateexception You Need To Use A Theme.appcompat Theme

Caused by java.lang.illegalstateexception you need to use a theme.appcompat theme

ProblemToday in the ZxingAndroid project, encountered such a problem, in the project AndroidManifest.xml file, add a MainActivity (extends from AppCompatActivity) When running app, the error is as follows:Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme ( or descendant) with this activity.Analysis:This problem has been successfully solved before. It was due to AppCompatActivity, which uses Theme. Theme.AppCompat should be used.And the above error, carefully checked, and did not use Theme, why is it wrong?Later on Found out why:You need to explicitly declare the theme of using Theme.AppCompat, Solution:Inheriting AppCompatActivity, the theme must explicitly use Theme.AppCompat, cannot use ThemeAdd android:theme='@style/Theme.AppCompat.Light' in AndroidManifest.xmlThe changed code is as follows: Inheritance Activity, theme using ThemePosted by leirenyuaninat Nov 14, 2017 - 9:31 PM.