【问题标题】:Failed to find style 'bottomNavigationStyle' in current theme在当前主题中找不到样式“bottomNavigationStyle”
【发布时间】:2018-08-11 07:09:47
【问题描述】:

我是使用 android studio 的初学者。我不知道为什么所有类型的容器(例如底部导航视图、选项卡布局、导航视图等)都会出现相同的错误,即无法在当前主题中找到样式。我使用了最新的 SDK 版本。我也尝试过更改主题,但仍然有错误。它还有一个错误“无法实例化一个或多个类”

apply plugin: 'com.android.application'
android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.etflin.etflin"
        minSdkVersion 27
        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-rc01'
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:recyclerview-v7:28.0.0-rc01'
implementation 'com.android.support:design:28.0.0-rc01'
implementation 'com.android.support:support-v4:28.0.0-rc01'}

这是布局中的代码:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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=".ChatRoom">

<android.support.design.widget.BottomNavigationView
    android:id="@+id/bottomNavigationView2"
    android:layout_width="0dp"
    android:layout_height="0dp"
    android:layout_marginBottom="8dp"
    android:layout_marginEnd="8dp"
    android:layout_marginStart="8dp"
    android:layout_marginTop="8dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>

【问题讨论】:

标签: android


【解决方案1】:

我找到了适合我的解决方案:

在 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.+"
            }
        }
    }
}

我在 Stack 上找到了这个, 你可以看看,它被命名为主题错误:Theme Error - how to fix?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-12-05
    • 2018-08-23
    • 2011-11-14
    • 2018-08-15
    • 2012-01-20
    • 2019-01-31
    • 2015-01-15
    相关资源
    最近更新 更多