Failed to find style 'coordinatorLayoutStyle' in current theme
Solution 1
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.
Solution 2
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'
Solution 3
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
Solution 4
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
Solution 5
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.
Jeet Dholakia
By Day - Tech ninja on Android and iOS By night - You'll see me in a co working space pretending to work Skills - Android and iOS
Updated on July 08, 2022Comments
-
Jeet Dholakia almost 2 years
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?
-
M at about 6 yearsWasted hours on this. Do you know why it happens ? I had no problem before but suddenly
-
Arbitur about 6 yearsAndroid is so weird sometimes eyeroll Thanks this fixed the issue for me.
-
Monte Creasor about 6 yearsThanks. It's ridiculous that Android Studio requires this.
-
Hassan Faghihi almost 6 yearsGood for you, it happen for me on starting up the Hello World app :D mean they introduce a built-in error :))
-
SMBiggs almost 6 yearsUnbelievably this works. But for god's sake, why? But did you know that I then deleted that line...and it still works! Indicates that somehow the editor got into a wicked state and this line somehow fixes it. Perhaps an invalidate/restart would have worked too?
-
SMBiggs almost 6 yearsOops, spoke too soon. Added another widget and the error popped back up. Guess I'll have to keep that line in my
styles.xml
. -
DanMossa almost 6 yearsAnd when you say application theme, you mean the styles.xml correct?
-
T-igra almost 6 years@DanMossa, yes - styles.xml. Or place the app theme in any .xml file in the /values folder.
-
Abhinav Saxena almost 6 yearsdoes not recognize in my 28 alpha support library.
-
Mihir Dave almost 6 yearsHello Please try to mention things like why it was not working. and changes you suggested why does that make difference.
-
Admin almost 6 yearsIt was not working because of an Android Studio bug.
-
Mujeebcpy almost 6 yearsi had to change implementation 'com.android.support:design:28.0.0-alpha3' also into alpha1
-
Livven almost 6 yearsAlternatively stay on SDK 28 and instead downgrade the support library versions from
28.0.0-alpha3
to28.0.0-alpha1
, as suggested in this answer stackoverflow.com/a/51091869/1488656 -
Livven almost 6 yearsAlternatively stay on SDK 28 and instead downgrade the support library versions from
28.0.0-alpha3
to28.0.0-alpha1
, as suggested in this answer stackoverflow.com/a/51091869/1488656 -
Jonas Grønbek almost 6 yearsThis one did it for me
-
Chris almost 6 yearsI had to do this to get mine working. Found it by using Android Studio intellisense and just beginning to type "Coord"
-
Chris almost 6 yearsIf it is saying it doesn't exist, trying just typing beginning to type "Coord" and it should give you some options. Mine was under
@style/Widget.Support.CoordinatorLayout
-
Manoranjan almost 6 yearsyeah it is under support public class CoordinatorLayout extends ViewGroup implements NestedScrollingParent2 java.lang.Object ↳ android.view.View ↳ android.view.ViewGroup ↳ android.support.design.widget.CoordinatorLayout
-
tiagocarvalho92 over 5 yearsIs it possible that Google is releasing RC an we still need to use 27?
-
Thiago Souza over 5 yearsThat's it, changing the SDK 28 to 27 and sync Gradle solved the problem.
-
Geraldo Neto about 5 yearsAs suggested by @Livven, there are some issues with the Support Library 28.0.0-alpha3.