【问题标题】:Android resource linking failed error: resource style/CardView error: failed linking referencesAndroid 资源链接失败错误:资源样式/CardView 错误:链接引用失败
【发布时间】:2019-08-31 13:41:44
【问题描述】:

我正在使用 androidx 支持库,包含用于

的库

com.google.android.material: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 Thread1,SO Thread2,SO 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”相同的错误,请帮我解决。

【问题讨论】:

  • 你能贴出你的代码吗?
  • 你添加compile 'com.android.support:cardview-v7:25.3.1' 这个库了吗
  • 能否提供一些代码,可能是你的xml文件和gradle文件
  • 我的项目中没有使用任何卡片视图,用我的依赖项更新了问题。
  • 您没有使用任何 CardViews?该错误在 style 属性中显示其预期的 cardviews 参数。如果您正在使用卡片视图,请确保您的 RecyclerView 未使用卡片视图。

标签: android material-design androidx


【解决方案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

问题解决后,如有需要,可以一一尝试使用具体版本。

【讨论】:

    【解决方案2】:

    这可能是主题和样式的问题。可能您的一个库希望该样式可用,但它没有找到它。

    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="cardViewStyle">@style/CardView</item>
    </style>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-05-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-31
      • 2022-10-13
      • 1970-01-01
      • 2019-02-01
      相关资源
      最近更新 更多