Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Duplicate value for resource 'attr/font' with config "

I really do now know why I got this error and how can I solve it. Actually I am not sure What I did right before I got this error.

Error Msg: /Users/hyun/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.0.1.arr/25699caf34fef6313d6ec32013a1a117f/res/values/values.xml error:duplicate value for resource 'attr/font' with config". error: resource previously defined here

/Users/hyun/Desktop/Laftel-Android/app/build/intermediates/incremental/mergeDbugResources/merged.dir/values/values.xml duplicate value for resource 'attr/font' with config ". resource previously defined here.

Java.util.concurrent.ExecutionException:com.android.tools.appt2.Aapt2Exception:AAPT2 error: check for details Execution failed for task ':app::mergeDebugResources'. Error: java.utilconcurrentExcutionException:com.android.tools.aapt2.Aapt2Exception : AAPT2 error: check logs for details

like image 861
Changhyun Eun Avatar asked Dec 06 '17 06:12

Changhyun Eun


4 Answers

It may the concept that makes conflicts with the logic that we have previously used for apply Custom fonts.

Previously

We have used below code for creating the custom attribute for the font.

    <declare-styleable name="CustomFont">
        <attr name="font" format="string" />
    </declare-styleable>

What I change

In my case, this was the issue and I have resolved it by renaming the attr name

    <declare-styleable name="CustomFont">
        <attr name="fontName" format="string" />
    </declare-styleable>

This same thing may apply if you are using any third party library or Custom View with "font" property

As per suggestion by reverie_ss Please Check your res->values->attrs.xml

like image 98
Tarun Dholakiya Avatar answered Nov 19 '22 15:11

Tarun Dholakiya


support library 26 added font attribute to XML elements like TextView, etc. In my case, I was using a library with custom views and a custom attribute app:font, so they collided. After renaming the library attribute to something else (textFont), all went good again. So, are you using a custom 'font' attribute somewhere? Did you update Gradle to supportLibrary 26 or 27 recently? If you can't override the attribute name, try rolling back to 25

like image 23
Pedro Gonzalez Avatar answered Nov 19 '22 16:11

Pedro Gonzalez


After migrating to AndroidX my error message was

error: duplicate value for resource 'attr/progress' with config ''

and I had a custom attribute defined for a custom view as the following:

<declare-styleable name="ProductionProgressItemView">
    <attr name="progressTitle" format="string"/>
    <attr name="progress" format="string"/>
    <attr name="progressPercent" format="integer"/>
</declare-styleable>

renaming progress to progressValue fixed the issue.

like image 23
luckyhandler Avatar answered Nov 19 '22 16:11

luckyhandler


i updated my android-X libraries to newer versions and i got this type of error in styles.xml

error: duplicate value for resource 'attr/progress' with config ''

this was my previous code there

<declare-styleable name="CircleProgressBar">
    <attr name="min" format="integer" />
    <attr name="max" format="integer" />
    <attr name="progress" format="integer" />
    <attr name="progressbarColor" format="color" />
    <attr name="progressBarThickness" format="dimension" />
</declare-styleable>

i changed the progress attribute value by refactoring it to progressValue like below.

<declare-styleable name="CircleProgressBar">
    <attr name="min" format="integer" />
    <attr name="max" format="integer" />
    <attr name="progressValue" format="integer" />
    <attr name="progressbarColor" format="color" />
    <attr name="progressBarThickness" format="dimension" />
</declare-styleable>

and it worked for me.

like image 6
Adnan Avatar answered Nov 19 '22 17:11

Adnan