主题错误 - 如何解决?

Theme Error - how to fix?

尝试了很多解决方案但没有帮助

参考:

但没有帮助

Render Problem:

Failed to find style 'coordinatorLayoutStyle' in current theme

Tip: Try to refresh the layout.

build.gradle 我项目的文件是:

buildscript {

repositories {
    google()
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.1.4'


    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

模块:应用程序

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "*****"
        minSdkVersion 19
        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-alpha1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    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'
    implementation 'com.android.support:design:28.0.0-alpha1'
}

主要ActivityXML代码

    <?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <android.support.design.bottomappbar.BottomAppBar
        android:id="@+id/bar"
        style="@style/Widget.MaterialComponents.BottomAppBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        app:navigationIcon="@drawable/ic_menu"
        app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
        app:fabAttached="true"
        app:backgroundTint="@color/colorPrimary"
        app:fabCradleVerticalOffset="12dp"/>

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_anchor="@id/bar"/>

</android.support.design.widget.CoordinatorLayout>

为什么我不将已编译的 SDK 版本 28 更改为 27 bcz 我想使用底部应用栏

Bottom App Bar Material Design

App Bars:Bottom- Material Design

此错误发生在您的渲染布局中,它是 Studio 的一部分,不在任何文件或库中

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

  2. 请通过选择菜单选项 "File" 重新启动 Android Studio → "Invalidate Caches / Restart"

  3. 解决方法:尝试使用 AS v1.3 预览或 M 预览渲染 使用 FrameLayout 进行设计并更改为 android.support.design.widget.CoordinatorLayout 正在调试。

这是 28.0.0 中的错误,唯一的解决方法(解决方法)是将其添加到您的 Build.gradle:

configurations.all {
        resolutionStrategy.eachDependency { DependencyResolveDetails details ->
            def requested = details.requested
            if (requested.group == "com.android.support") {
                if (!requested.name.startsWith("multidex")) {
                    details.useVersion "27.1.1"
                }
            }
        }
    }

不知何故,这绕过了问题并为此使用了 27 支持库。否则,您可能想将 Android Studio 更新到金丝雀通道版本或使用向后支持库,如 27.1.1 等。