Android资源链接失败错误:资源样式/ CardView错误:链接引用失败

问题描述 投票:1回答:2

我使用的是androidx支持库,包含了库

com.google.android.material:材料:1.1.0-alpha05

我在构建应用程序时遇到错误,我没有在我的应用程序中使用任何卡片视图。

Android resource linking failed

error: resource style/CardView (aka com.app.myapp:style/CardView) not found.
error: style attribute 'attr/cardElevation (aka com.app.myapp:attr/cardElevation)' not found.

error: style attribute 'attr/cardBackgroundColor (aka com.app.myapp:attr/cardBackgroundColor)' not found.

error: style attribute 'attr/cardCornerRadius (aka com.app.myapp:attr/cardCornerRadius)' not found.

error: failed linking references.

已经尝试过使用SO Thread1SO Thread2SO Thread3

但尚未找到任何解决方案。

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.1.0-alpha04'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.core:core-ktx:1.1.0-alpha05'
    implementation 'androidx.cardview:cardview:1.0.0' // Included
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.android.material:material:1.1.0-alpha05'
    implementation 'com.jakewharton.timber:timber:4.7.1'
    implementation 'com.google.code.gson:gson:2.8.2'
    implementation 'com.nabinbhandari.android:permissions:3.8'
    implementation project(':volley-master')
    testImplementation 'junit:junit:4.12'

}

我无法使用任何带有“com.google.android.material”的视图同样的错误,请帮我解决一下。

android material-design androidx
2个回答
1
投票

首先,尝试删除以下依赖项,因为com.google.android.material:material:1.1.0-alpha05已经拥有它们,它将自动提取正确的版本。

implementation 'androidx.appcompat:appcompat:1.1.0-alpha04'
implementation 'androidx.cardview:cardview:1.0.0'
// Remove it also if you are not using anything from the legacy support library.
implementation 'androidx.legacy:legacy-support-v4:1.0.0' 

另外,确保你已经完成了compileSdkVersion是28。

解决问题后,如果需要,您可以再次尝试逐个使用特定版本。


0
投票

可能这是主题和风格的问题。可能你的一个库期待这种风格可用而且它找不到它。

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="cardViewStyle">@style/CardView</item>
</style>
© www.soinside.com 2019 - 2024. All rights reserved.