错误:(4,42)找不到与给定名称匹配的资源('cardBackgroundColor'与值'?android:attr / colorBackgroundFloating')

时间:2017-02-17 09:21:45

标签: java android android-studio

美好的一天,

我可以知道为什么我的Recycler cardview消息日志显示此错误? 有没有人遇到过这个错误?

D:\New folder\DrawerWithSwipeTabs\app\build\intermediates\res\merged\debug\values-v23\values-v23.xml

Error:(4, 42) No resource found that matches the given name (at 'cardBackgroundColor' with value '?android:attr/colorBackgroundFloating').

Error:(4, 42) No resource found that matches the given name (at 'cardBackgroundColor' with value '?android:attr/colorBackgroundFloating').

它自动弹出到D:\ New folder \ DrawerWithSwipeTabs \ app \ build \ intermediates \ res \ merged \ debug \ values-v23 \ values-v23.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="CardView" parent="Base.CardView">
        <item name="cardBackgroundColor">?android:attr/colorBackgroundFloating</item>
    </style>
</resources>

build.gradle(项目)

// Top-level build file where you can add configuration options common to all sub-projects/modules.

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

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

allprojects {
    repositories {
        jcenter()
    }
}

build.gradle(模块:应用)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.androidbelieve.drawerwithswipetabs"
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:22.2.1'
    compile 'com.android.support:design:22.2.1'
    compile 'com.android.support:recyclerview-v7:25.1.1'
    compile 'com.android.support:support-v4:25.1.1'
    compile 'com.android.support:cardview-v7:25.1.1'

}

1 个答案:

答案 0 :(得分:0)

parent="Base.CardView"

这个父类不是在sdk 22版中引入的。 要实现这一点,您需要将minSdk版本和库版本更改为sdk-version 23.

这样的事情。

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"

defaultConfig {
    applicationId "com.androidbelieve.drawerwithswipetabs"
    minSdkVersion 15
    targetSdkVersion 23
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
}
}

dependencies {

compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
compile 'com.android.support:recyclerview-v7:23.2.1'
compile 'com.android.support:support-v4:23.2.1'
compile 'com.android.support:cardview-v7:23.2.1'
}