Failed to find style 'coordinatorLayoutStyle' in current theme In Android Studio 3.1
Asked Answered
M

6

14

The Android Studio 3.1 layout preview fails to find style 'coordinatorLayoutStyle' in the current theme.

Failed to instantiated one or more classes.
 Exception shown are :-
java.lang.ClassNotFoundException: android.view.View$OnUnhandledKeyEventListener
Mendymene answered 14/6, 2018 at 11:35 Comment(0)
M
17

This happened due to use of alpha version SDK 28

We need to change the android { ... } in "build.gradle" in app file
compileSdkVersion 28 to compileSdkVersion 27
targetSdkVersion 28 to targetSdkVersion 27

Also, try to change implementations like
implementation 'com.android.support:appcompat-v7:28.0.0-alpha3' to
implementation 'com.android.support:appcompat-v7:27.1.1'

Hope this works!

For Android Studio v3.1.*, in addition we need change:
implementation 'com.android.support:design:28.0.0-alpha3' to
implementation 'com.android.support:design:27.1.1'

Morelos answered 7/7, 2018 at 5:39 Comment(3)
android requires to target the latest version, anyway to fix this still targeting 28?Homebrew
No,we can't . Since,the Android SDK version 28 is still in beta and rc-01 version as on this date , we have to wait until we get a stable version of SDK 28Morelos
This did work for me also, Thanks for sharing. Remember for Android Studio v3.1.* also change support to: implementation 'com.android.support:support-v4:27.1.1' The errors still continue in the error list, but it works now fine without any problems just igonring them.Eschatology
A
5

you can fix this issue by adding this script to the app module build.gradle, in the android section

configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
    def requested = details.requested
    if (requested.group == "com.android.support") {
        if (!requested.name.startsWith("multidex")) {
            details.useVersion "27.+"
        }
     }
   }
}
Armhole answered 2/8, 2018 at 9:57 Comment(1)
Can confirm that this does the trick for 3.1.3 but just wondering if there is any benefit to this over explicitly setting version 27 as per https://mcmap.net/q/130987/-failed-to-find-style-39-coordinatorlayoutstyle-39-in-current-theme-in-android-studio-3-1 ?Envoy
T
2

This appears to be a bug in the current version of Android Studio (3.1.3) as I was encountering the same thing. I downloaded the beta build from here and opened my existing project and the errors disappeared.

https://developer.android.com/studio/preview/?utm_source=android-studio

Not exactly a fix but hopefully it will get you back up and running.

Telium answered 25/6, 2018 at 22:45 Comment(1)
Thank You , 'JOSH' It's main error of 'coordinatorLayoutStyle' was Solved. But I have encountered with a new problem help me with it too it says - tools:ignore="MissingConstraints"Mendymene
A
1

Update

1. com.android.support:appcompat stable version 28.0.0 is released. So no need to downgrade version. Just use 28.0.0.

def supportVersion = "28.0.0"
implementation "com.android.support:appcompat-v7:$supportVersion"
implementation "com.android.support:design:$supportVersion"

You can ignore design library if you don't need it.

2: You also need to update your compileSdkVersion & targetSdkVersion to remove some gradle warnings.

compileSdkVersion 28
targetSdkVersion 28

Never use alpha versions of any library, because alpha, beta and rc versions may have bugs. And you don't want to face these types of errors often.

Important Suggestion

I suggest you migrate to androidx because android will not update support library after 28.0.0, all updates will be available to androidx package only. Check related answer.

Adze answered 6/9, 2018 at 11:3 Comment(0)
D
0

This is fixed in Android Studio 3.2.

Decrial answered 16/11, 2018 at 13:36 Comment(0)
F
-1

Go to app/res/styles and change the Theme.AppCompat.Light.DarkActionBar for this one Base.Theme.AppCompat.Light.DarkActionBar

Ferdinande answered 19/6, 2018 at 0:15 Comment(1)
This fix may work in older versions of Android Studio, but not in 3.1.3.Telium

© 2022 - 2024 — McMap. All rights reserved.