duplicate value for resource 'attr/layout_anch

2019-09-19 17:09发布

问题:

Android resource compilation failed
Output:  H:\OzelDersim\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:1019: error: duplicate value for resource 'attr/layout_anchorGravity' with config ''.
H:\OzelDersim\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:1019: error: resource previously defined here.

Command: C:\Users\Emre Hmrc\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.0-4818971-windows.jar\0d3beb61e3dde971f53232b7b0aae803\aapt2-3.2.0-4818971-windows\aapt2.exe compile --legacy \
        -o \
        H:\OzelDersim\app\build\intermediates\res\merged\debug \
        H:\OzelDersim\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml
Daemon:  AAPT2 aapt2-3.2.0-4818971-windows Daemon #0

回答1:

In the module build.gradle (app), add support:design in dependencies:

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

Replace the version with the one used in your module and don't forget to Sync.

To check the latest version or for more information.



回答2:

In your module build.gradle file check for a line

implementation 'com.android.support:support-v4:27.1.1'

remove it and rebuild.


I encountered the same error today after adding the default "SettingsActivity" files. The wizard inserted this line in the build.gradle file, causing the error.

Hint: use a version control system, it helps to discover such subtle errors easily.