Dhruv Thakkar
Dhruv Thakkar

Reputation: 412

After Updating Android studio to 3.1.2 , I get "Failed to load AppCompat ActionBar with unknown error. "

I tried looking other similar questions on stackoverflow, they advice us to changw version of "buildToolsVersion" but I dont see word like that in my gradle file.

My Gradle File (PROJECT):-

buildscript {

repositories {
    google()
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.1.2'


    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}

allprojects {
repositories {
    google()
    jcenter()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

My build.gradle (Module:app): This the my second gradle file

     apply plugin: 'com.android.application'

 android {
 compileSdkVersion 28
 defaultConfig {
    applicationId "com.example.dhruv.testhello"
    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.1'
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'
 }

Upvotes: 12

Views: 7741

Answers (9)

Yusuf Adefolahan
Yusuf Adefolahan

Reputation: 342

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

Upvotes: -2

Khemraj Sharma
Khemraj Sharma

Reputation: 58974

Update 2

As you can see in support 28.0.0 release notes.

This will be the last feature release under the android.support packaging, and developers are encouraged to migrate to AndroidX 1.0.0

Android will not update support libraries from now. So I suggest you migrate to androidx before they deprecated support libraries.

Update

Support 28.0.0 is released, so you can use this stable version.

implementation 'com.android.support:design:28.0.0'

I suggest never use alpha versions, because alpha, beta versions have bugs, that are testing libraries.

Upvotes: 3

Noor Hossain
Noor Hossain

Reputation: 41

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

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

replace the line with:

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

That means: Add the word "Base." starting the name of the parent theme.

Upvotes: 0

Adedoyin Akande
Adedoyin Akande

Reputation: 2559

At the time of this answer Android Studio 3.1.4 is out with Android Support 28.0.0 Release Candidate(Potential Final, Beta) so please update. Well, here is a config that will certainly work for you.

targetSdkVersion 28
com.android.support:*:28.0.0-rc01

Where * is the resource type.

Upvotes: 0

Hossein Seifi
Hossein Seifi

Reputation: 1420

I had the same problem. I searched so much and I finally found that appcompat-v7:28.0.0-alpha3 has some bug with "Design View" part of Android Studio.

So I suggest to change com.android.support:appcompat-v7:28.0.0-alpha3 to com.android.support:appcompat-v7:28.0.0-alpha1 version and then click File -> Invalidate Caches / Restart. Volla everything is OK.

Of course you should have internet access to download com.android.support:appcompat-v7:28.0.0-alpha1

Upvotes: 20

zakir
zakir

Reputation: 11

yes its work,

implementation 'com.android.support:design:28.0.0-alpha3' to

implementation 'com.android.support:design:28.0.0-alpha1'

After that got to File and click -> Invalidate Caches / Restart

Upvotes: 0

Mateusz Czerwiński
Mateusz Czerwiński

Reputation: 63

I was helped by Hossein Seifi's reply but with a change

implementation 'com.android.support:design:28.0.0-alpha3'

to

implementation 'com.android.support:design:28.0.0-alpha1'

and click File -> Invalidate Caches / Restart

Upvotes: 3

Dhruv Thakkar
Dhruv Thakkar

Reputation: 412

In styles.xml,

Changing the theme from Theme.AppCompat.Light.DarkActionBar to Base.Theme.AppCompat.Light.DarkActionBar has worked for me.

Upvotes: 0

primo
primo

Reputation: 1472

module app gradle file looks like this...In your file you are missing buildToolsVersion, adding this may help you

  apply plugin: 'com.android.application'

 android {
  //changes
  compileSdkVersion 26
buildToolsVersion "27.0.3"
 defaultConfig {
    applicationId "com.example.dhruv.testhello"
   minSdkVersion 24
    targetSdkVersion 26
    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'])

//changes
compile 'com.android.support:appcompat-v7:26.0.2'
compile 'com.android.support.constraint:constraint-layout:1.0.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'
 }

Upvotes: 0

Related Questions