找不到与给定名称匹配的资源('dialogCornerRadius'与值'?android:attr / dialogCornerRadius')

问题描述 投票:22回答:8

任何人都可以帮助我为什么会在下面收到错误?

错误:(7,41)找不到与给定名称匹配的资源(在'dialogCornerRadius'中,值为'?android:attr / dialogCornerRadius')。

apply plugin: 'com.android.application'

//Add these lines
def Base_URL = '"' + WEBServiceBaseURL + '"' ?: '"Define BASE URL"';
def SMS_Base_URL = '"' + WEBServiceBaseSMSURL + '"' ?: '"Define SMS BASE URL"';

android.buildTypes.each { type ->
    type.buildConfigField 'String', 'Base_URL', WEBServiceBaseURL
    type.buildConfigField 'String', 'SMS_Base_URL', WEBServiceBaseSMSURL
}

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.1"
    defaultConfig {
        applicationId "com.bla.bla"
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled  true
    }
    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:26.+'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:design:+'
    compile files('libs/jxl-2.6.jar')
    compile 'com.google.gms:google-services:+'

    compile 'com.google.firebase:firebase-core:11.8.0'
    compile 'com.google.firebase:firebase-messaging:11.8.0'
}

apply plugin: 'com.google.gms.google-services'
android gradle dependencies build-error
8个回答
49
投票

我选择修复了这个问题

API 27+:Android API 27,P预览(预览)

在项目结构设置中。下图显示了我的设置。构建应用程序时出现的13个错误已经消失。

My Gradle settings


13
投票

设置你的compileSdkVersion 28让android studio下载平台文件


3
投票

将行compile 'com.android.support:design:+'更改为compile 'com.android.support:design:26.+'

构建项目时的gradle依赖关系是拉下最新版本,因为+告诉它“获取最新版本”。 26.+将告诉构建过程仅更新最新版本的v26。

或者更加具体和安全,将线路更改为特定版本,完全避免使用+。即compile 'com.android.support:design:27.1.0'


3
投票

如果您在应用程序级别gradle如果您使用compileSdkVersion = 27然后它将无法正常工作。您必须使用版本28。

compileSdkVersion 28 buildToolsVersion '28.0.3'


2
投票

更改gradle中的以下依赖项:


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

至:

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

'com.android.support:appcompat-v7:26.+'

至:

'com.android.support:appcompat-v7:26.1.0'

请注意,您可以指定任何版本,但请确保它们都具有相同的版本。

这将确保不创建values-28.xml文件。


0
投票

在Everybody的帮助下,我可以解决这个问题并在较低版本中运行应用程序。

我更新的build.gradle如下所示。

特别感谢那里的所有天才!

apply plugin: 'com.android.application'
android.buildTypes.each { type ->
    type.buildConfigField 'String', 'Base_URL', WEBServiceBaseURL
    type.buildConfigField 'String', 'SMS_Base_URL', WEBServiceBaseSMSURL
}

android {
    compileSdkVersion 27
    buildToolsVersion "26.0.2"
    defaultConfig {
        applicationId "com.dummy.dummy"
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled  true
    }
    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

        }
    }

}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:26.+'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:design:26.+'
    compile files('libs/jxl-2.6.jar')
    compile 'com.google.gms:google-services:+'
    compile 'com.google.firebase:firebase-core:11.8.0'
    compile 'com.google.firebase:firebase-messaging:11.8.0'
}

apply plugin: 'com.google.gms.google-services'

0
投票

忘记动态依赖关系并用固定的特定版本替换它们:

错了:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:26.+'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:design:+'
    compile files('libs/jxl-2.6.jar')
    compile 'com.google.gms:google-services:+'

    compile 'com.google.firebase:firebase-core:11.8.0'
    compile 'com.google.firebase:firebase-messaging:11.8.0'
}

正确:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:26.1.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:design:26.1.0'
    compile files('libs/jxl-2.6.jar')
    compile 'com.google.gms:google-services:3.1.1'

    compile 'com.google.firebase:firebase-core:11.8.0'
    compile 'com.google.firebase:firebase-messaging:11.8.0'
}

0
投票

迁移到AndroidX失败后得到同样的错误。我还原了Android Studio所做的所有更改,清理了项目,使缓存/重启无效以及许多其他事情,但没有运气。最后我发现Android Studio在gradle.properties中添加了两行:

android.useAndroidX=true
android.enableJetifier=true

删除这些行后一切恢复正常。

© www.soinside.com 2019 - 2024. All rights reserved.