解决support包引起的AndroidStudio编译报错

有时我们在引用support包的时候会遇到下面的错误,

AGPBI: {"kind":"error","text":"error: resource android:attr/colorError not found.","sources":[{"file":"C:\\Users\\qwe\\.gradle\\caches\\transforms-1\\files-1.1\\appcompat-v7-27.0.0.aar\\e789b9218a563087f526e1e34511490a\\res\\values-v26\\values-v26.xml","position":{"startLine":8,"startColumn":4,"startOffset":431,"endLine":11,"endColumn":12,"endOffset":652}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"error: resource android:attr/colorError not found.","sources":[{"file":"C:\\Users\\qwe\\.gradle\\caches\\transforms-1\\files-1.1\\appcompat-v7-27.0.0.aar\\e789b9218a563087f526e1e34511490a\\res\\values-v26\\values-v26.xml","position":{"startLine":12,"startColumn":4,"startOffset":657,"endLine":15,"endColumn":12,"endOffset":891}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"error: style attribute \u0027android:attr/keyboardNavigationCluster\u0027 not found.","sources":[{"file":"C:\\Users\\qwe\\.gradle\\caches\\transforms-1\\files-1.1\\appcompat-v7-27.0.0.aar\\e789b9218a563087f526e1e34511490a\\res\\values-v26\\values-v26.xml","position":{"startLine":16,"startColumn":4,"startOffset":896,"endColumn":92,"endOffset":984}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"error: resource android:attr/fontStyle not found.","sources":[{"file":"C:\\Users\\qwe\\.gradle\\caches\\transforms-1\\files-1.1\\appcompat-v7-27.0.0.aar\\e789b9218a563087f526e1e34511490a\\res\\values\\values.xml","position":{"startLine":251,"startColumn":4,"startOffset":27028,"endColumn":68,"endOffset":27092}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"error: resource android:attr/font not found.","sources":[{"file":"C:\\Users\\qwe\\.gradle\\caches\\transforms-1\\files-1.1\\appcompat-v7-27.0.0.aar\\e789b9218a563087f526e1e34511490a\\res\\values\\values.xml","position":{"startLine":251,"startColumn":4,"startOffset":27028,"endColumn":68,"endOffset":27092}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"error: resource android:attr/fontWeight not found.","sources":[{"file":"C:\\Users\\qwe\\.gradle\\caches\\transforms-1\\files-1.1\\appcompat-v7-27.0.0.aar\\e789b9218a563087f526e1e34511490a\\res\\values\\values.xml","position":{"startLine":251,"startColumn":4,"startOffset":27028,"endColumn":68,"endOffset":27092}}],"original":"","tool":"AAPT"}
:app:processDebugResources
error: failed linking references.
:app:processDebugResources FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugResources'.
> Failed to process resources, see aapt output above for details.

{"kind":"error","text":"error: resource android:attr/colorError not found."

{"kind":"error","text":"error: resource android:attr/font not found."

* What went wrong:
Execution failed for task ':app:processDebugResources'.
> Failed to process resources, see aapt output above for details.

报各种资源找不到的错!!!

 

原因是

compileSdkVersion 25

低于

implementation 'com.android.support:appcompat-v7:27.0.0'

sdk编译版本低于support包的版本一般就会报这个错,当然并不是绝对的,一般是高版本的support包中的资源文件在底版本sdk中找不到的时候才会报错。

比如你compileSdkVerion 26,support版本用27.0.0的时候就不会报错。

但是如果你打开app下的build.gradle发现上述两个版本号一致,怎么也报错了,那你这个工程中肯定还有其他module,在其他module中引用了比主app中compileSdkVerion高的support包了

Studio在打包的时候会检测所有module中的support包,对于不同版本的情况,最终取最高版本的support包来为所有module进行编译。

原因知道了,解决办法就简单了,要么升sdk版本,要么降support版本。

  • 9
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值