0

My app is failing to run in the emulator. The error cited is java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.

I've read a number of similar questions, including: .IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity

ActionBarCompat: java.lang.IllegalStateException: You need to use a Theme.AppCompat

But none of these have worked.

The code in the res>values>styles.xml file is:

<resources>

    <style name = "AppBaseTheme" parent = "TextAppearance.AppCompat">
        <item name = "android:colorPrimary">@android:color/holo_blue_bright</item>
        <item name = "android:colorPrimaryDark">@android:color/holo_blue_dark</item>
        <item name = "android:colorAccent">@android:color/holo_red_dark</item>


    </style>



</resources>

The code in the src>main>AndroidManifest.xml file is:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.android.hbpm1">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppBaseTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

I'd be very grateful if anyone could help :)

N3R4ZZuRR0
  • 2,400
  • 4
  • 18
  • 32
Kate
  • 15
  • 3

1 Answers1

0

Application theme can not be <style name = "AppBaseTheme" parent = "TextAppearance.AppCompat">, because TextAppearance theme can't be used for Application theme at all. So, use any Theme.AppCompat as the default theme for your application. For this, I can give an example:

<style name = "AppBaseTheme" parent = "Theme.AppCompat">

or

<style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar"> 

etc.

Hope it will work

A S M Sayem
  • 2,010
  • 2
  • 21
  • 28