Failed to find style 'coordinatorLayoutStyle' in current theme

AndroidAndroid LayoutAndroid StudioAndroid Coordinatorlayout

Android Problem Overview


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?

Android Solutions


Solution 1 - Android

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 - Android

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 - Android

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 - Android

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 - Android

 <style name="Theme.Shrine" parent="Theme.MaterialComponents.Light.NoActionBar">
    <item name="coordinatorLayoutStyle">@style/Widget.Support.CoordinatorLayout</item>
</style>

Add in your material theme.

Solution 6 - Android

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.

Solution 7 - Android

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.

Solution 8 - Android

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 enter image description here

Solution 9 - Android

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.

Solution 10 - Android

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.

Solution 11 - Android

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

Solution 12 - Android

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

Solution 13 - Android

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: https://stackoverflow.com/questions/13439486/missing-styles-is-the-correct-theme-chosen-for-this-layout/31860142

Solution 14 - Android

<!-- 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.

Solution 15 - Android

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.

Solution 16 - Android

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

Solution 17 - Android

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'

Solution 18 - Android

This is sdk 28 issue

Check your build.gradle (Module: app) file and change:

compileSdkVersion 28

targetSdkVersion 28

To:

compileSdkVersion 27

targetSdkVersion 27

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJeet DholakiaView Question on Stackoverflow
Solution 1 - AndroidT-igraView Answer on Stackoverflow
Solution 2 - AndroidGeraldo NetoView Answer on Stackoverflow
Solution 3 - Androidtony MaciasView Answer on Stackoverflow
Solution 4 - AndroidAnu BhallaView Answer on Stackoverflow
Solution 5 - AndroidMuzammil HusnainView Answer on Stackoverflow
Solution 6 - AndroidkaspiotrView Answer on Stackoverflow
Solution 7 - AndroidJeet DholakiaView Answer on Stackoverflow
Solution 8 - AndroidNishanView Answer on Stackoverflow
Solution 9 - AndroidPhillipView Answer on Stackoverflow
Solution 10 - AndroidlandongtomView Answer on Stackoverflow
Solution 11 - AndroidGeorgy IvanovView Answer on Stackoverflow
Solution 12 - AndroidVectorView Answer on Stackoverflow
Solution 13 - AndroidGokul Nath KPView Answer on Stackoverflow
Solution 14 - Androidsounak mondalView Answer on Stackoverflow
Solution 15 - AndroidSoufianeKView Answer on Stackoverflow
Solution 16 - AndroidIvan AndreyshevView Answer on Stackoverflow
Solution 17 - AndroidNeeraj SinghView Answer on Stackoverflow
Solution 18 - AndroidSachin JagtapView Answer on Stackoverflow