Failed to find style 'coordinatorLayoutStyle' in current theme - android

I'm using the latest version of android studio (3.0), along with latest build tools (27) and similar API level.
The layout does not get rendered in the design tab and it's causing a lot of trouble especially that I'm using coordinator layout.
How do I get around this problem?

I solved this rendering problem by simply inserting this line into the application theme (the app theme is usually placed in styles.xml).
[SDK 28]
<style name="AppTheme">
<item name="coordinatorLayoutStyle">#style/Widget.Support.CoordinatorLayout</item>
</style>
[SDK 27]
<style name="AppTheme">
<item name="coordinatorLayoutStyle">#style/Widget.Design.CoordinatorLayout</item>
</style>
As suggested by #Chris. If the IDE does not find the CoordinatorLayout in Widget.Support or Widget.Design, just start typing "CoordinatorLayout" and it should give you some options.

Turns out the new SDK 28 is unfortunately introducing this error on Android Studio when you create a new project.
How to solve:
Check your build.gradle (Module: app) file and change:
compileSdkVersion 28
targetSdkVersion 28
To:
compileSdkVersion 27
targetSdkVersion 27
Also, make sure you are using the right dependencies version:
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'

implementation 'com.android.support:appcompat-v7:28.0.0-alpha3' in
build.gradle(module) change alpha 3 to alpha 1. sync and you should be good to go. I spent almost a day trying to figure this out. none of these answers worked for me. hope this helps

I was also facing the same problem. Nothing like changing theme from Layout preview window helped me.
Solution: I updated my build.gradle(app) with:
dependencies {
implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.android.support:design:27.0.2'
}
One more thing:
compileSdkVersion 27
targetSdkVersion 27

<style name="Theme.Shrine" parent="Theme.MaterialComponents.Light.NoActionBar">
<item name="coordinatorLayoutStyle">#style/Widget.Support.CoordinatorLayout</item>
</style>
Add in your material theme.

For Android Studio 3.1.4 users:
I've tried marked answer but it didn't work for me.
Inserting this line:
<style name="AppTheme.NoActionBar">
<item name="coordinatorLayoutStyle">#style/Widget.Design.CoordinatorLayout</item>
</style>
into the application theme doesn't solve the rendering problem so I've undone that change.
Solution:
I've made this changes in my build.gradle(Module:app) file:
Before change:
android {
compileSdkVersion 28
defaultConfig {
targetSdkVersion 28
}
}
}
dependencies {
implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
implementation 'com.android.support:design:28.0.0-rc01'
}
After change:
android {
compileSdkVersion 27
defaultConfig {
targetSdkVersion 27
}
}
}
dependencies {
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
}
It worked for me perfectly. Hope that will be useful.

Thanks for the response, I found the solution tinkering with the code,
I had tools:showIn attribute enabled in the parent layout of a fragment, which I moved to a viewpager, it was previously embedded in a host activity, lint did not catch it though, which is a bit surprising.

I think it is a common issue in android studio 3.0+,
Hopefully they will fix it next update. In the Android Studio Preview 3.2 it works fine.
Download Android Studio Preview

As an aside, in design view of Android Studio, if I add the following to the styles.xml file:
<style name="Coordinator">
<item
name="coordinatorLayoutStyle">#style/Widget.Design.CoordinatorLayout</item>
</style>
and add the following to the CoordinatorLayout in the layout's xml resource file
<android.support.design.widget.CoordinatorLayout
android:theme="#style/Coordinator"
android:orientation="vertical"
android:id="#+id/sample_layout_id"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/sample_background"
tools:theme="#style/Coordinator">
then, at least, the design view stops generating the missing coordinatorLayoutStyle error.

My Android studio version 3.1.3.
i'm worked with uninstall ALL SDK version 28. Step is Open SDK Manager > SDK Platforms > Show package Details > Untick SDK 28 > apply and Create new project.

I have the same problem but on the Android studio 3.1.4
So, at first I have done the following in build.gradle
Replace this:
implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
implementation 'com.android.support:design:28.0.0-rc01'
implementation 'com.android.support:support-v4:28.0.0-rc01'
with that:
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
implementation 'com.android.support:design:28.0.0-alpha1'
implementation 'com.android.support:support-v4:28.0.0-alpha1'
But somehow after project rebuild the problem repeats again.
So, I have go this way:
Here is my project gradle.build
buildscript {
ext.kotlin_version = '1.2.41'
ext.android_support = '27.1.1'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And here app build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 27
defaultConfig {
applicationId "*****.******"//Replace with your own ID
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
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'
}
And this solve my problem
Thank you

I will post an answer The other answers may work but no one should need to download Preview Version and doing Material Design with no Action Bar is not the way to START developing apps with Android Studio
Our version of Android Studio is 3.1.4
Our default API is 28
Our FIX is to downgrade to API 26 YOU do this by clicking File -> Project Structure then highlight app Under the Properties TAB Change Compile Sdk version to API 26 Now click on the Falavors TAB and change Target Sdk version to 26
Then in build.gradle(module:app) add these changes
implementation 'com.android.support:appcompat-v7:27.0.0'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
I guess one could always justify this slow FIX by Google to learn to use the ToolBar

This maybe existing issue: https://issuetracker.google.com/issues/37048767
Render using other versions of Android (say Android API 22).
Or check for any typos or invalid XML entries.
Refer here: Missing styles. Is the correct theme chosen for this layout?

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="coordinatorLayoutStyle">#style/Widget.Design.CoordinatorLayout</item>
</style>
just add coodrinatorLayoutStyle as an item in style.xml and it worked for me.

Just Change implementation 'com.android.support:appcompat-v7:28.0.0-alpha3' and
'com.android.support:design:28.0.0-alpha3' to alpha 1.
That's how i solved the problem.

I solve this problem when update all SDK tools in IDE and update Android Studio to 3.2.1

its working for me try it
compileSdkVersion 28
defaultConfig {
minSdkVersion 16
targetSdkVersion 28
}
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'

This is sdk 28 issue
Check your build.gradle (Module: app) file and change:
compileSdkVersion 28
targetSdkVersion 28
To:
compileSdkVersion 27
targetSdkVersion 27

Related

Android Studio components aren't displaying and app does not run

I am new to Android Studio and want to know why it does not really work for me.
Basically, I just started learning Android Studio watching an online course, so I am just doing the same thing what the lecturer does on the videos, but the result never turns out the same.
Firstly I want to let you know that I have not touched anything. But Android Studio does not show any of components, such as textView, and when I run it, the ADB(the Emulator) never runs the app but only shows the default screen of an Android phone.
I better attach some screenshots of my Android Studio to show you what is going on.
As you can see from this picture, there is a textView component but it does not appear on the screen that is in the center.
As I wrote above, I did not touch anything. It is just right after I create a new project. No matter what component I add, it never shows up.
I have no idea if it would matter but if you look at the top right, an error occurs (red exclamation mark) that is saying "Render Problem: Failed to load AppCompat ActionBar with unknown error".
I have tried to solve this error for several hours and could not really find a solution to this too.
And when I run the app (by pressing green arrow button), here's what happens.
It just stays on this screen. Nothing really happens after this.
What should I do to see my components and to make it run the app? What am I missing? I really have done exactly the same as the online course I am watching and I see no one is having the problem I am facing now.
Any help?
In case of it will be needed, I am uploading both of my gradle files too:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
// 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
}
This is a gradle file build.gradle (Project: project name)
And the following is a gradle file build.gradle (Module: app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.auclo.exampleapp"
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-rc02'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
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'
}
And styles.xml
Thanks.
This is an issue of version 28, you should downgrade to version 27 until the problem is solved.
Go to your app/Gradle Scripts/build.gradle (Module:app)
1
Change this line:
compileSdkVersion 28
to
compileSdkVersion 27
2
Change this line:
targetSdkVersion 28
to
targetSdkVersion 27
3
Change this line:
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
to
implementation 'com.android.support:appcompat-v7:27.1.1'
Then Android Studio will ask you to Sync the files, and you do so by clicking in Sync Now
Keep learning how to code, and soon Android will solve this problem. You can see more about this discussion here.
I wanted to wait till i'm clear but since everyone is telling him to downgrade the project, here I go.
There's a bug in the newer versions. So if you want to run your project on sdk 28, in your res/values/styles.xml modify the AppTheme style from
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
to
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
Basically waht you have to do is add Base to whatever is already there.
Or
As the others said you can downgrade your project to:
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
But I think you should always learn on the latest so you're free to choose either options :)
Go to styles.xml and change
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
to
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
Change Depandency
This is an issue of version 28, you should downgrade to version 27 until the problem is solved.
compileSdkVersion 28 to compileSdkVersion 27
targetSdkVersion 28 to targetSdkVersion 27
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
replace with
implementation 'com.android.support:appcompat-v7:27.1.1'

Android Studio 3.1.3 having issues with Constraint layout

I'm trying to start a new project here but this problem is appearing. I can run the project and deploy it in an emulator but this Render problem and Using private resources is ticking me off. I've already tried all the possible solutions found in the internet but it just can't solve the problem
<?xml version="1.0" encoding="utf
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context=".MainActivity"
tools:showIn="#layout/activity_main">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />
</android.support.constraint.ConstraintLayout>
Style
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
Build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.acer.myapplication3"
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"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:28.0.0-alpha3'
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'
}
Had the same issue - went to SDK manager and installed additional SDK platforms; Oreo 8.1. It seems the issue was that the 'new' API 28 still has issues. It says partially installed, but I basically just checked the boxes for lower API's and it downloaded/installed:
Additionally, I changed my build.gradle file's SDK version, buildTools, appcompat, and design versions as below. It works now and I will move back to API 28 at a later stage when these issues have been resolved.
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
...
minSdkVersion 15
targetSdkVersion 27
...
dependencies {
implementation 'com.android.support:appcompat-v7:27.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:design:27.0.0'
}
You just need to change the following codes from the dependencies section of your build.gradle file:
From:
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
implementation 'com.android.support:design:28.0.0-rc02'
To:
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
implementation 'com.android.support:design:28.0.0-alpha1'
And then sync your project.
I had the same issues. For me, the reason is my project "Automatically convert third-party libraries to use AndroidXhas". Check if your problem same as mine? please simply follow the two steps described here.
to make it easy:
1st step:
Please check your gradle.properties, if you see the following lines, you might have the exact same issues as mine. You can firstly delete them.
android.useAndroidX=true
android.enableJetifier=true
2nd step: in main activity, I changed
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
into
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
Everything works all of sudden!
Try to use this:
dependencies {
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.1'
}
Instead of constraint-layout:1.1.2.
This solved my issue.
Add 'Base.' before 'Theme.AppCompat.Light.DarkActionBar'
in styles.xml .
Worked for me.
On the left-hand side, click app.
Then, open the res folder.
Open up the values folder.
Click on the 'styles.xml' folder.
Change the parent variable to "Base.Theme.AppCompact.Light.DarkActionBar"
Make sure you unchecked OFF LINE option in settings > gradle, then
sync the project again while connected on network

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'
}
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
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
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.
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'
}
In styles.xml,
Changing the theme from Theme.AppCompat.Light.DarkActionBar to Base.Theme.AppCompat.Light.DarkActionBar has worked for me.
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
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.
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.
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

Android Studio Gradle Build failing - asking for a sdk version that doesn't exist

24 hours ago my project built perfectly, no errors. Without changing a single piece of code, it will no longer build when I have resumed work.
Checking out to older working commits now produces the same error.
These are the error codes I get:
Information:Gradle tasks [assemble]
Error:(9, 5) error: resource android:attr/dialogCornerRadius not found.
/home/liam/.gradle/caches/transforms-1/files-1.1/appcompat-v7-28.0.0-alpha1.aar/536e4dd78846259cf8bef0fd6a3ea0e6/res/values/values.xml
I think that this has been caused by Android P being released and my Android Studio automatically upgrading or something like that. Which would explain why old commits that worked get this same error.
This would be a very new issue, which would explain why I cannot find a solution to it yet.
Searching these error codes leads to a similar issue that was resolved by changing the SDK version in the gradle build file. My problem differs from this because changing to SDK 28 (I'm pretty sure 28 doesn't even exist) leads to android studio saying this package isn't available/doesn't exist for download.
How to find issue Android SDK 3.0 Error:(9, 5) error: resource android:attr/colorError not found
Clicking on the first mentioned error codes leads to a file called v28/values-v28.xml being opened.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Base.Theme.AppCompat" parent="Base.V28.Theme.AppCompat"/>
<style name="Base.Theme.AppCompat.Light" parent="Base.V28.Theme.AppCompat.Light"/>
<style name="Base.V28.Theme.AppCompat" parent="Base.V26.Theme.AppCompat">
<!-- We can use the platform styles on API 28+ -->
<item name="dialogCornerRadius">?android:attr/dialogCornerRadius</item>
</style>
<style name="Base.V28.Theme.AppCompat.Light" parent="Base.V26.Theme.AppCompat.Light">
<!-- We can use the platform styles on API 28+ -->
<item name="dialogCornerRadius">?android:attr/dialogCornerRadius</item>
</style>
</resources>
Here are my gradle files:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.timelord.timelord.timelord"
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'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:+'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation files('libs/joda-time-2.9.9.jar')
}
And
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// 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
}
You have the design lib version with + in your build.gradle which means it will download the latest version. So please set it to 26.1.0 and it should work. The support 28 is in alpha and was released yesterday with the new android P preview
Make sure in your app's build.gradle you have these:
dependencies {
compile 'com.android.support:support-v13:27.+'
compile 'com.android.support:design:27.+'
}

android.support.v7.widget.Toolbar VectorDrawableCompat IllegalStateException when using support lib 24+

I've started a new project in Android Studio and configured my gradle build settings. When I add an android.support.v7.widget.Toolbar to a layout, I get the following error when in design view. Keep note that this error only shows up when previewing with an API less than 21 (specifically APIs 16 - 19). Everything works fine when I preview with API 21 - 24.
I have looked at a number of solutions and tried them, but none have solved the issue. One thing I tried doing was adding this to my gradle:
vectorDrawables.useSupportLibrary = true
But that didn't solve the issue. I tried configuring my compiledSdkVersion to 23, buildToolsVersion to 23.0.3. This did not change anything. If I change the support library versions to 23.4.0 or below, then the issue is resolved. As soon as I change it back up to 24.0.0 or higher then it returns.
Clearing the cache, cleaning the project and rebuilding, and invalidating the cache and restarting did not solve the issue.
The following classes could not be instantiated:
- android.support.v7.widget.Toolbar (Open Class, Show Exception, Clear Cache)
Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when in the IDE
Exception Details
java.lang.IllegalStateException: This app has been built with an incorrect configuration.
Please configure your build for VectorDrawableCompat.
at android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup(AppCompatDrawableManager.java:692)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:186)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:181)
at android.support.v7.widget.TintTypedArray.getDrawable(TintTypedArray.java:67)
at android.support.v7.widget.Toolbar.<init>(Toolbar.java:298)
at android.support.v7.widget.Toolbar.<init>(Toolbar.java:229)
...
invalid drawable tag vector
Here is my app build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.1" // https://developer.android.com/studio/releases/build-tools.html
defaultConfig {
applicationId "org.path.path"
minSdkVersion 16
targetSdkVersion 23
versionCode 0
versionName "0.0.0"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
ext {
supportLibVersion = '24.0.0' // https://developer.android.com/topic/libraries/support-library/revisions.html
}
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile "com.android.support:appcompat-v7:${supportLibVersion}"
compile "com.android.support:design:${supportLibVersion}"
compile "com.android.support:cardview-v7:${supportLibVersion}"
compile "com.android.support:recyclerview-v7:${supportLibVersion}"
}
My project build.gradle is using classpath 'com.android.tools.build:gradle:2.1.2'
This is the toolbar xml:
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/toolbar_main"
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
android:minHeight="?attr/actionBarSize"
android:elevation="4dp"
android:background="#color/colorPrimary"
app:theme="#style/ActionBarThemeOverlay"
app:popupTheme="#style/ActionBarPopupThemeOverlay"/>
And finally, my styles.xml:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
<!-- ActionBar -->
<style name="ActionBarPopupThemeOverlay" parent="ThemeOverlay.AppCompat.Dark" />
<style name="ActionBarThemeOverlay" parent="ThemeOverlay.AppCompat.Dark">
<item name="android:textColorPrimary">#color/text_on_primary</item>
<item name="android:textColorSecondary">#color/subtitle_on_primary</item>
</style>
Is this a bug, or am I just not able to use the support library versions 24 or higher? I'm not aware of any other configurations to change as the exception tried to direct.
Check this issue:
appcompat-v7 24.0.0 is incompatible with rasterized vectors
Make sure you are using gradle version greater than 2.0
buildscript {
...
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
}
}

Categories

Resources