CoordinatorLayout 在 Android Studio 3.1.3 中不工作?

CoordinatorLayout not working in Android Studio 3.1.3?

我知道这个问题已被问过很多次,但我已经尝试了大部分解决方案,并且 none 对我有用。 这是我第一次使用 android studio 3.1.3,我正在学习如何使用 android studio 中的基本模板选项创建简单应用程序的教程。我面临的问题是;

Render Problem Failed to find style 'coordinatorLayoutStyle' in current theme

我已经尝试将其添加到 build.gradle 文件中:

compile 'com.android.support:design:24.1.1'

也这个进style.xml

<style name="AppTheme.NoActionBar">
  <item name="coordinatorLayoutStyle">@style/Widget.Design.CoordinatorLayout</item>
</style>

styles.xml

<resources>

    <!-- 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>
    </style>

    <style name="AppTheme.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
    </style>


    <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

    Couldn't resolve resource @style/Widget.Design.CoordinatorLayout<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

</resources>

build.gradle

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.notes"
        minSdkVersion 23
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    implementation 'com.android.support:design:28.0.0-alpha3'
    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'
}

我遇到了同样的问题。我尝试按照步骤 , but still the problem persists. 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 and visit here 学习如何 运行 它与 Android Studio 稳定版

或者你可以尝试将你的设计库版本降低到27。(并且编译sdk版本也降低到27)

dependencies { implementation 'com.android.support:appcompat-v7:27.0.2' implementation 'com.android.support:design:27.0.2' }

尝试在 styles.xml 中的主题前添加 "Base",如下所示:- "Base.Theme.AppCompat.Light.DarkActionBar"

此问题的永久解决方案:将构建 gradle(模块应用程序)更改为实施 com.android.support:appcompat-v7:28.0.0-alpha1

更改构建 gradle(模块应用) 来自:com.android.support:appcompat-v7:28.1.1-alpha3

到:com.android.support:appcompat-v7:27.1.1

1.try 首先:在 Gradle(模块应用程序)中针对 appcompat 进行更改:

implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'

2。如果它不起作用,请清理您的项目,然后再次构建它。 就我而言,它奏效了。