Failed to find style 'coordinatorLayoutStyle' in current theme

75,317

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.

Share:
75,317
Jeet Dholakia
Author by

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, 2022

Comments

  • Jeet Dholakia
    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
    M at about 6 years
    Wasted hours on this. Do you know why it happens ? I had no problem before but suddenly
  • Arbitur
    Arbitur about 6 years
    Android is so weird sometimes eyeroll Thanks this fixed the issue for me.
  • Monte Creasor
    Monte Creasor about 6 years
    Thanks. It's ridiculous that Android Studio requires this.
  • Hassan Faghihi
    Hassan Faghihi almost 6 years
    Good for you, it happen for me on starting up the Hello World app :D mean they introduce a built-in error :))
  • SMBiggs
    SMBiggs almost 6 years
    Unbelievably 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
    SMBiggs almost 6 years
    Oops, 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
    DanMossa almost 6 years
    And when you say application theme, you mean the styles.xml correct?
  • T-igra
    T-igra almost 6 years
    @DanMossa, yes - styles.xml. Or place the app theme in any .xml file in the /values folder.
  • Abhinav Saxena
    Abhinav Saxena almost 6 years
    does not recognize in my 28 alpha support library.
  • Mihir Dave
    Mihir Dave almost 6 years
    Hello Please try to mention things like why it was not working. and changes you suggested why does that make difference.
  • Admin
    Admin almost 6 years
    It was not working because of an Android Studio bug.
  • Mujeebcpy
    Mujeebcpy almost 6 years
    i had to change implementation 'com.android.support:design:28.0.0-alpha3' also into alpha1
  • Livven
    Livven almost 6 years
    Alternatively stay on SDK 28 and instead downgrade the support library versions from 28.0.0-alpha3 to 28.0.0-alpha1, as suggested in this answer stackoverflow.com/a/51091869/1488656
  • Livven
    Livven almost 6 years
    Alternatively stay on SDK 28 and instead downgrade the support library versions from 28.0.0-alpha3 to 28.0.0-alpha1, as suggested in this answer stackoverflow.com/a/51091869/1488656
  • Jonas Grønbek
    Jonas Grønbek almost 6 years
    This one did it for me
  • Chris
    Chris almost 6 years
    I had to do this to get mine working. Found it by using Android Studio intellisense and just beginning to type "Coord"
  • Chris
    Chris almost 6 years
    If 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
    Manoranjan almost 6 years
    yeah 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
    tiagocarvalho92 over 5 years
    Is it possible that Google is releasing RC an we still need to use 27?
  • Thiago Souza
    Thiago Souza over 5 years
    That's it, changing the SDK 28 to 27 and sync Gradle solved the problem.
  • Geraldo Neto
    Geraldo Neto about 5 years
    As suggested by @Livven, there are some issues with the Support Library 28.0.0-alpha3.