50

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

Dharmishtha
  • 1,313
  • 10
  • 21
Changhyun Eun
  • 539
  • 1
  • 4
  • 9

14 Answers14

47

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

Tarun Dholakiya
  • 829
  • 1
  • 10
  • 16
41

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

Alireza Noorali
  • 3,129
  • 2
  • 33
  • 80
Pedro Gonzalez
  • 1,429
  • 2
  • 19
  • 30
23

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.

Shashanth
  • 4,995
  • 7
  • 41
  • 51
luckyhandler
  • 10,651
  • 3
  • 47
  • 64
6

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.

Adnan
  • 171
  • 2
  • 4
3

repeat in implementation 'com.android.support.constraint:constraint-layout:2.0.4'

I remove it.

Ado
  • 411
  • 4
  • 9
2

I am using supporting library 27.1.1 and definitely targetSDKVersion is 27. There was a conflict with other library in my case It was google play services which also adds supporting library but with older version so there are two libraries which creates issue.

Add this in project level build.gradle file

task clean(type: Delete) {
delete rootProject.buildDir
}

subprojects {
    project.configurations.all {
        resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'com.android.support'
                    && !details.requested.name.contains('multidex') ) {
                details.useVersion "26.1.0"
            }
        }
    }
}

I found this here link

Zeeshan
  • 1,625
  • 17
  • 25
2

If you are migrating to androidx, try putting the below code in gradle.properties, if this file doesn't exist inside your project directory create one and put the below lines. This solved

Duplicate value for resource 'attr/.*' with config ''

error in my case

android.enableJetifier=true
android.useAndroidX=true
David Passmore
  • 6,089
  • 4
  • 46
  • 70
  • 3
    Looks like error is still occurring in my case: **AAPT: error: duplicate value for resource 'attr/progress' with config** – IgorGanapolsky Jun 27 '19 at 22:54
2

I also had this problem...

My PROBLEM : I used same attribute name (ex. editable) in tow xml : attr_1.xml and attr_2.xml

attr_1.xml :

<resources>
    <declare-styleable name="CustomContainerEditText">
        <attr name="android:text" format="string" />
        <attr name="editable" format="string" />
    </declare-styleable>
</resources>

attr_2.xml :

<resources>
    <declare-styleable name="CustomContainerEditText">
        <attr name="editable" format="string" />
    </declare-styleable>
</resources>

SOLUTION : (Short Answer) I just remove format="String" from one of xml attribute file (like attr_2.xml) and my problem fixed.

attr_2.xml :

<resources>
    <declare-styleable name="CustomContainerEditText">
        <attr name="editable" />
    </declare-styleable>
</resources>
ultra.deep
  • 1,699
  • 1
  • 19
  • 23
  • Did not work for me. I have two libraries using the same attr name. Removed the format attribute in one of them. The compiler still gives the error of the question. – anunezr Mar 15 '22 at 12:07
1

try compileSdkVersion 25, then it will be all ok. support library 26 added font attribute to xml elements like TextView, etc, so if you want to use sdkversion 26 then you need to renaming the library attribute to something else (textFont), all went good again

Alwayss Bijoy
  • 778
  • 9
  • 15
1

I faced the same issue. In my case I just had

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

and I added

implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'

and it worked for me!

Volodya Lombrozo
  • 2,325
  • 2
  • 16
  • 34
0

In my case : error: duplicate value for resource 'attr/mode' with config ''

It was directly related to the following library

implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha2'

I had to rename my declare-styleable which had a name as mode to something such as custom_mode. It then fixed the error.

Mr T
  • 1,409
  • 1
  • 17
  • 24
0

In My case, textColor and text_background_color are creating the problem but after adding the format It's working fine before adding format

<declare-styleable name="OtpView">
    <attr name="android:inputType">number</attr>
    <attr name="textColor"/>
    <attr name="OtpView_android_textColor" />
    <attr name="text_background_color"/>
    <!--<attr name="text_background_color" format="color">?back_icon_color</attr>-->
    <attr name="otp" format="string" />
    <attr name="lineColor" format="reference|color" />
</declare-styleable>

after adding the format to textColor and text_beckground_color property it get solved

<declare-styleable name="OtpView">
    <attr name="android:inputType">number</attr>
    <attr name="textColor" format="string"/>
    <attr name="OtpView_android_textColor" />
    <attr name="text_background_color" format="string"/>
    <!--<attr name="text_background_color" format="color">?back_icon_color</attr>-->
    <attr name="otp" format="string" />
    <attr name="lineColor" format="reference|color" />
</declare-styleable>
Virendra Varma
  • 895
  • 1
  • 12
  • 23
0

Just keep reducing the version of the dependency mentioned in the path
In your case its: /Users/hyun/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.0.1.arr/25699caf34fef6313d6ec32013a1a117f/res/values/values.xml

So reducing the version number for appcompat-v7-27.0.1 to 27.0.0 might work.

If it doesn't work then keep on reducing the version number and re-build the project each time until it works.

chris
  • 194
  • 2
  • 10
0

This worked for me

implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
Sam
  • 241
  • 3
  • 7