Style attribute attr/@attr/minTextSize not found

2019-02-27 06:00发布

问题:

I have trying since long to identify the issue but unfortunately not able to

If I do

android.enableAapt2=true

The code works fine, but removing the same(Which should compulsorily be) there is a error thrown saying

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

Here are the details of the versions I am using

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"

In Gradle.Propeties

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

Support Library version

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

error outputpath

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

回答1:

Well, in my case it happened when i upgraded build tools, to resolve this issue, you should have two attr files like in this image:

Add these lines in both of attr.xml files:

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

This resolved the issue i was facing. Hope it help someone.



回答2:

The issue is with some of the gradles added in project. Actually the libraries internally have defined the attribute minTextSize

Due to latest updates and compatibility the attr was not found.

To identify I have defined same attr as

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

in attrs.xml in my app module. Compiling the same thrown error of duplicate value and path and from that path I have found the library which needs to be updated.

Updating to the latest of all library version have solved the issue.