Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Duplicate value for resource 'attr/strokeWidth' with config

Tags:

java

android

I just updated the support library from 27 to 28 and it is not successfully building with the following error:

Android resource compilation failed
Output:  /AndroidProjects/Brand App/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:1052: error: duplicate value for resource 'attr/strokeWidth' with config ''.
/AndroidProjects/Brand App/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:1052: error: resource previously defined here.

Command: /Users/apple/.gradle/caches/transforms-1/files-1.1/aapt2-3.2.0-4818971-osx.jar/509e285e62be11c8bb7437cdd445c1df/aapt2-3.2.0-4818971-osx/aapt2 compile --legacy \
        -o \
        /AndroidProjects/Brand App/app/build/intermediates/res/merged/debug \
        /AndroidProjects/Brand App/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml
Daemon:  AAPT2 aapt2-3.2.0-4818971-osx Daemon #0
like image 910
makkhokher Avatar asked Sep 26 '18 09:09

makkhokher


Video Answer


2 Answers

Faced the same issue, mine was attr/shape in config file, the issue is basically related to conflict of libraries that are using android default libraries, please paste the complete issue also update any thirdparty libraries you are using and it will work. I update one of the libraries and the issue is resolved. as i was using old version of com.facebook.shimmer and i just updated it in gradle and it worked.

like image 176
Awais Tariq Avatar answered Nov 09 '22 23:11

Awais Tariq


This happened to me because I had the following attribute definition that conflicted with the new strokeWidth in the android support library:

 <declare-styleable name="CountdownView">
     <attr name="widgetHeight" format="dimension" />
     <attr name="widgetWidth" format="dimension" />
     <attr name="animationDurationMs" format="integer" />
     <attr name="animationRepeatCount" format="integer" />
     <!-- strokeWidth was the conflict -->
     <attr name="strokeWidth" format="integer" />
     <attr name="paintTextSize" format="dimension" />
 </declare-styleable>

The support library used format="dimension" while I was using format="integer". Changing to format="dimension" solved the problem, and was the correct format anyway:

 <declare-styleable name="CountdownView">
     <attr name="widgetHeight" format="dimension" />
     <attr name="widgetWidth" format="dimension" />
     <attr name="animationDurationMs" format="integer" />
     <attr name="animationRepeatCount" format="integer" />
     <!-- strokeWidth now matches support library -->
     <attr name="strokeWidth" format="dimension" />
     <attr name="paintTextSize" format="dimension" />
 </declare-styleable>
like image 44
Heath Borders Avatar answered Nov 09 '22 22:11

Heath Borders