Failed to find style 'coordinatorLayoutStyle' in current theme
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.