user2384694 user2384694 - 1 month ago 14
Android Question

why error only in 4.3 but works for 5.x/6.x IllegalStateException: You need to use a Theme.AppCompat 4.3

I found following SO questions on the same topic

You need to use a Theme.AppCompat theme (or descendant) with this activity

My question is more about why it only happened on device with Android 4.3. Same code works with Android 5/6

public class MyActivity extends AppCompatActivity {


styles.xml



<!-- Base application theme. -->
<style name="AppTheme" parent="@android:style/Theme.Holo.Light">
<item name="android:windowBackground">@null</item>
</style>
<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">@drawable/background_splash</item>
</style>




v21/styles.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
</style>
</resources>


Can you please explain?

Answer

I believe the answer is in your code. styles.xml is used on devices with Android 4.3, and v21/styles.xml on device with Android 5+ Try to remove v21/styles.xml and see what happen on Android 5+.