未找到样式属性 attr/@attr/minTextSize

Style attribute attr/@attr/minTextSize not found

长期以来我一直在尝试找出问题所在,但不幸的是没能做到

如果我这样做

android.enableAapt2=true

代码工作正常,但删除相同的(应该是强制性的)会抛出一个错误说

\incremental\mergeDevDebugResources\merged.dir\values\values.xml:5887: error: style attribute 'attr/@attr/minTextSize' not found.

以下是我使用的版本的详细信息

classpath 'com.android.tools.build:gradle:3.2.0'
classpath 'com.jakewharton:butterknife-gradle-plugin:8.4.0'
classpath 'com.google.gms:google-services:4.0.1'
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.6.1"

在Gradle.Propeties

distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-all.zip

支持库版本

compile 'com.android.support:appcompat-v7:28.0.0'

错误输出路径

\.gradle\caches\transforms-1\files-1.1\appcompat-v7-28.0.0-alpha3.aare6fcc6d3eea5b57de6d7aedf3f55c0\res\values\values.xml

问题出在项目中添加的一些 gradle 上。 实际上库内部已经定义了属性 minTextSize

由于最新的更新和兼容性,未找到 attr

为了识别我定义了与

相同的属性
<attr name="minTextSize" format="integer">16</attr>

in attrs.xml 在我的应用程序模块中。 编译重复值和路径的相同抛出错误,并从该路径找到需要更新的库。

更新到最新的所有库版本已经解决了这个问题。

好吧,就我而言,它发生在我升级构建工具时,为了解决这个问题, 你应该有两个 attr 文件,如下图所示:

两个 attr.xml 文件中添加这些行:

 <style name="SquareTextView">
         <item name="minTextSize">5dp</item>
    </style>
    <declare-styleable name="SquareTextView"><attr format="dimension" name="minTextSize"/></declare-styleable>

这解决了我面临的问题。希望对大家有帮助。

如果您没有 attrs.xml,请创建一个。之后添加此代码段。

<?xml version="1.0" encoding="utf-8"?> 
<resources>
           <style name="SquareTextView">
               <item name="minTextSize">5dp</item>
           </style>
           <declare-styleable name="SquareTextView">
             <attr format="dimension" name="minTextSize"/>
           </declare-styleable>
 </resources>