No resource found that matches the given name (at 'cardBackgroundColor' with value

本文介绍了一种在Android项目中引入包含CardView的新模块时,因版本不一致导致的资源冲突问题及其解决方法。通过调整项目的编译版本及支持包版本,成功解决了编译错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

问题

问题描述
自己写了一个模块(其中使用了CardView),现在想导入到之前的项目中。导入完成,编译报如下错误:
**app\build\intermediates\res\merged\debug\values-v23\values-v23.xml 。
No resource found that matches the given name (at ‘cardBackgroundColor’ with value ‘?android:attr/colorBackgroundFloating’)。**

这里写图片描述

意思是(翻译):
没有发现资源匹配给指定的名称(在 ‘cardbackgroundcolor ‘赋值给‘?android:attr/ colorbackgroundfloating”)。
问题分析
1,报错是找不到资源;2,由于是找不到资源,大胆猜测可能是导入的新模块中使用的资源,老项目中由于版本低,没有支持文件;3,故重点考虑版本问题。
解决办法
1,将项目Gradle中的版本号改为本地最新;

compileSdkVersion 25
buildToolsVersion "25.0.0"

2,将Gradle中支持包版本更新;

compile 'com.android.support:support-v4:25.0.0'

3,构建Gradle,成功。

参考资源

这是什么问题 Error:Execution failed for task ':app:processDebugResources'. > Failed to execute aapt Error:com.android.ide.common.process.ProcessException: Error while executing process E:\AndroidSDK\build-tools\26.0.2\aapt.exe with arguments {package -f --no-crunch -I E:\AndroidSDK\platforms\android-26\android.jar -M \\?\E:\chapter02\Register\app\build\intermediates\manifests\full\debug\AndroidManifest.xml -S E:\chapter02\Register\app\build\intermediates\res\merged\debug -m -J \\?\E:\chapter02\Register\app\build\generated\source\r\debug -F E:\chapter02\Register\app\build\intermediates\res\debug\resources-debug.ap_ --custom-package com.example.dell.register02 -0 apk --output-text-symbols \\?\E:\chapter02\Register\app\build\intermediates\symbols\debug --no-version-vectors} Error:org.gradle.process.internal.ExecException: Process 'command 'E:\AndroidSDK\build-tools\26.0.2\aapt.exe'' finished with non-zero exit value 1 Error:java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Error while executing process E:\AndroidSDK\build-tools\26.0.2\aapt.exe with arguments {package -f --no-crunch -I E:\AndroidSDK\platforms\android-26\android.jar -M \\?\E:\chapter02\Register\app\build\intermediates\manifests\full\debug\AndroidManifest.xml -S E:\chapter02\Register\app\build\intermediates\res\merged\debug -m -J \\?\E:\chapter02\Register\app\build\generated\source\r\debug -F E:\chapter02\Register\app\build\intermediates\res\debug\resources-debug.ap_ --custom-package com.example.dell.register02 -0 apk --output-text-symbols \\?\E:\chapter02\Register\app\build\intermediates\symbols\debug --no-version-vectors} Error:(165, 31) No resource found that matches the given name (at 'layout_above' with value '@id/btn_submit'). Error:(165, 31) No resource found that matches the given name (at 'layout_above' with value '@id/btn_submit'). E:\chapter02\Register\app\build\intermediates\res\merged\debug\layout\activity_main.xml E:\chapter02\Register\app\src\main\res\layou
03-15
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值