Home » Android » android – Failed to load AppCompat ActionBar with unknown error?

android – Failed to load AppCompat ActionBar with unknown error?

Posted by: admin June 15, 2020 Leave a comment

Questions:

Error Snap

build.gradle file

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "io.dume.dume"
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso- 
 core:3.0.2'
 }

I just created a new projects and found this error dramatically on activity_main.xml i did not changed anything . Is there any Fix?

How to&Answers:

I had the same problem. Seems it is a Android Studio bug.

In your styles xml-file change this:

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

to this:

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

Works for me.

Answer:

Set your target sdk version to 27 .
Set your compile sdk version to 27 .
And app compat version from 28.0.0-alpha3 to 27.1.1 .

If you still want to use sdk version 28

Just replace alpha3 to alpha1 without changing anything else

Answer:

This worked for me when that happened, I dont know why it doesn’t work with 28:

//use this instead 
compileSdkVersion 27
buildToolsVersion '27.0.3'
targetSdkVersion 27

dependencies{

//switch to these
implementation 'com.android.support:appcompat-v7:27.0.0-alpha'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:27.0.0'

}

Answer:

I fix this error using 3 methods on YouTube

Solution

Answer:

This worked for me.

Open, res –> values –> styles.xml, here you will find a line like this:

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">

change it to:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">

In otherwords, change DarkActionBar to NoActionBar