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

今天再使用科大讯飞语音识别SDK进行语音识别功能实现时,莫名的引入了这个错误。不得不吐槽Android Studio再引入别的包时太容易出现冲突,然后导致无法找到R文件,项目无法执行。

1. 具体报错

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

2. 报错原因

在build项目时默认使用了values-v28下的style.xml,但无法找到与该style.xml相匹配的资源

3. 解决办法

修改build.gradle文件,取消动态依赖,指定特定版本的依赖

修改前:

compileSdkVersion 26
buildToolsVersion '26.0.2'
targetSdkVersion 26
compile 'com.android.support:recyclerview-v7:+'
compile 'com.android.support:appcompat-v7:+'

修改后:

compileSdkVersion 26
buildToolsVersion '26.0.2'
targetSdkVersion 26
compile 'com.android.support:recyclerview-v7:26.0.2'
compile 'com.android.support:appcompat-v7:26.0.2'

使用“+”时,会自动使用最新版本的values进行build,所以最好指定SDK的版本,避免不必要的错误

猜你喜欢

转载自www.cnblogs.com/huiAlex/p/9108945.html