Duplicate value for resource 'attr/font' with config "
AndroidAndroid ResourcesAndroid Problem Overview
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
Android Solutions
Solution 1 - Android
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
Solution 2 - Android
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
Solution 3 - Android
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.
Solution 4 - Android
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.
Solution 5 - Android
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
Solution 6 - Android
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
Solution 7 - Android
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>
Solution 8 - Android
repeat in implementation 'com.android.support.constraint:constraint-layout:2.0.4'
I remove it.
Solution 9 - Android
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
Solution 10 - Android
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.
Solution 11 - Android
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>
Solution 12 - Android
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.
Solution 13 - Android
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!