You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

更新appcompat-v7:27.1.1触发'attr/font'重复资源错误,需保留buildTools26+

Fixing "duplicate value for resource 'attr/font' with config ''" after upgrading buildToolsVersion to 26.0.2

Hey there, I’ve dealt with this exact resource conflict issue when upgrading build tools for third-party integrations like PushIO. Let’s work through how to fix this without rolling back your build tools version:

1. Understand Why This Happens

Android 8.0 (API 26) added a system-level font attribute to its core resources. The error pops up because one of your dependencies—most likely an older version of PushIO or a transitive dependency it pulls in—has its own custom definition of the font attribute that clashes with the system’s new one.

2. Override the Conflicting Attribute (Quickest Fix)

You can explicitly tell the build system to prioritize your project’s definition of the font attribute over the conflicting one from the dependency:

  • Open or create res/values/attrs.xml in your app module.
  • Add the following code (make sure the root <resources> tag includes the tools namespace):
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools">
    <!-- Override the conflicting font attribute to match the system's definition -->
    <attr name="font" format="reference" tools:override="true" />
</resources>

The tools:override="true" flag resolves the duplicate error by forcing your project’s attribute definition to take precedence.

3. Upgrade PushIO to the Latest Version

Check if PushIO has released an updated SDK version. Most reliable libraries push updates to support newer Android API levels, and they’ve likely fixed this resource conflict by renaming their custom font attribute or adding compatibility for API 26+. Upgrading might eliminate the issue entirely.

4. Pinpoint and Exclude the Conflicting Dependency

If updating PushIO isn’t an option, find out which specific dependency is causing the clash:

  • Run this command in your project root to generate a full dependency tree:
./gradlew app:dependencies
  • Scan the output for libraries that include a custom font attribute (focus on PushIO and its transitive dependencies).
  • Once you identify the culprit, exclude its conflicting resource module from your dependency declaration in your app-level build.gradle:
implementation('com.pushio:pushio-sdk:X.X.X') {
    exclude group: 'com.example.conflicting-group', module: 'conflicting-module'
}

Replace the placeholder group and module names with the actual conflicting ones from your dependency tree.

5. Clean and Rebuild

After applying any of the fixes above, don’t forget to:

  • Run Build > Clean Project in Android Studio.
  • Rebuild the project to ensure all changes take effect.

内容的提问来源于stack exchange,提问作者Tarun Dholakiya

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 09:34:10