发布于 4年前

Android Gradle报错:No resource found that matches the given name (at 'dialogCornerRadius' with value '?android:attr/dialogCornerRadius').

记录问题,项目突然报错:

app/build/intermediates/res/merged/debug/values-v28/values-v28.xml Error:(7, 41) No resource found that matches the given name (at 'dialogCornerRadius' with value '?android:attr/dialogCornerRadius'). 
...
Error:Execution failed for task ':app:processDebugResources'. com.android.ide.common.process.ProcessException: Failed to execute aapt

定位到原因,导致错误的地方是依赖的design包:

implementation 'com.android.support:design:+'

这里使用了design:+,它会更新到最近的发布的版本28的包。解决方法,把design固定在一个可用的版本:

implementation 'com.android.support:design:26.1.0'

有类似的错误,可以定位是不是最近的更新导致。

原配置如下:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.example"
        minSdkVersion 24
        targetSdkVersion 26
        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:26.1.0'
    implementation 'com.android.support:design:+'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    //...
}
©2020 edoou.com   京ICP备16001874号-3