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

问题描述 投票:2回答:2

我很快就试图找出问题,但遗憾的是无法解决

如果我做

android.enableAapt2 =真

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

\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.Properties中

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.aar\33e6fcc6d3eea5b57de6d7aedf3f55c0\res\values\values.xml
android gradle android-studio-3.0
2个回答
2
投票

好吧,在我的情况下,当我升级构建工具时,为了解决这个问题,你应该有两个attr文件,如下图所示:enter image description here

在两个attr.xml文件中添加以下行:

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

这解决了我面临的问题。希望它可以帮助某人。


0
投票

问题在于项目中添加了一些渐变。实际上,库内部已经定义了属性minTextSize

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

确定我已定义相同的attr为

<attr name="minTextSize" format="integer">16</attr>

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

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


-2
投票

如果您没有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>
© www.soinside.com 2019 - 2024. All rights reserved.