Duplicate value for resource '...' with config '' in Android Studio

0

I'm encountering this error:

Caused by: java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource compilation failed
C:\Users\ASUS\.gradle\caches\transforms-2\files-2.1\fbc90cfd248703a7e0db4d61153601cb\res\values\values.xml:14:5-370: AAPT: error: duplicate value for resource 'attr/layout_scrollFlags' with config ''.

C:\Users\ASUS\.gradle\caches\transforms-2\files-2.1\fbc90cfd248703a7e0db4d61153601cb\res\values\values.xml:14:5-370: AAPT: error: resource previously defined here.

C:\Users\ASUS\.gradle\caches\transforms-2\files-2.1\fbc90cfd248703a7e0db4d61153601cb\res\values\values.xml:15:5-180: AAPT: error: duplicate value for resource 'attr/behavior_peekHeight' with config ''.

C:\Users\ASUS\.gradle\caches\transforms-2\files-2.1\fbc90cfd248703a7e0db4d61153601cb\res\values\values.xml:15:5-180: AAPT: error: resource previously defined here.

C:\Users\ASUS\.gradle\caches\transforms-2\files-2.1\dc61720a1def28041d1d315e107b6600\res\values\values.xml:142:5-149:95: AAPT: error: duplicate value for resource 'attr/layout_collapseMode' with config ''.

C:\Users\ASUS\.gradle\caches\transforms-2\files-2.1\dc61720a1def28041d1d315e107b6600\res\values\values.xml:142:5-149:95: AAPT: error: resource previously defined here.

C:\Users\ASUS\.gradle\caches\transforms-2\files-2.1\fbc90cfd248703a7e0db4d61153601cb\res\values\values.xml:19:5-827: AAPT: error: duplicate value for resource 'attr/layout_anchorGravity' with config ''.

C:\Users\ASUS\.gradle\caches\transforms-2\files-2.1\fbc90cfd248703a7e0db4d61153601cb\res\values\values.xml:19:5-827: AAPT: error: resource previously defined here.

I don't know what are duplicated in my values.xml file. Here are the lines that is mentioned:

<declare-styleable name="AppBarLayout_LayoutParams"><attr name="layout_scrollFlags"><flag name="scroll" value="0x1"/><flag name="exitUntilCollapsed" value="0x2"/><flag name="enterAlways" value="0x4"/><flag name="enterAlwaysCollapsed" value="0x8"/><flag name="snap" value="0x10"/></attr><attr format="reference" name="layout_scrollInterpolator"/></declare-styleable>
<declare-styleable name="BottomSheetBehavior_Params"><attr format="dimension" name="behavior_peekHeight"/><attr format="boolean" name="behavior_hideable"/></declare-styleable>
<declare-styleable name="CollapsingAppBarLayout_LayoutParams"><attr name="layout_collapseMode"><enum name="none" value="0"/><enum name="pin" value="1"/><enum name="parallax" value="2"/></attr><attr format="float" name="layout_collapseParallaxMultiplier"/></declare-styleable>
<declare-styleable name="CollapsingToolbarLayout"><attr format="dimension" name="expandedTitleMargin"/><attr format="dimension" name="expandedTitleMarginStart"/><attr format="dimension" name="expandedTitleMarginTop"/><attr format="dimension" name="expandedTitleMarginEnd"/><attr format="dimension" name="expandedTitleMarginBottom"/><attr format="reference" name="expandedTitleTextAppearance"/><attr format="reference" name="collapsedTitleTextAppearance"/><attr format="color" name="contentScrim"/><attr format="color" name="statusBarScrim"/><attr format="reference" name="toolbarId"/><attr name="collapsedTitleGravity"><flag name="top" value="0x30"/><flag name="bottom" value="0x50"/><flag name="left" value="0x03"/><flag name="right" value="0x05"/><flag name="center_vertical" value="0x10"/><flag name="fill_vertical" value="0x70"/><flag name="center_horizontal" value="0x01"/><flag name="center" value="0x11"/><flag name="start" value="0x00800003"/><flag name="end" value="0x00800005"/></attr><attr name="expandedTitleGravity"><flag name="top" value="0x30"/><flag name="bottom" value="0x50"/><flag name="left" value="0x03"/><flag name="right" value="0x05"/><flag name="center_vertical" value="0x10"/><flag name="fill_vertical" value="0x70"/><flag name="center_horizontal" value="0x01"/><flag name="center" value="0x11"/><flag name="start" value="0x00800003"/><flag name="end" value="0x00800005"/></attr><attr format="boolean" name="titleEnabled"/><attr name="title"/></declare-styleable>
<declare-styleable name="CoordinatorLayout"><attr format="reference" name="keylines"/><attr format="reference" name="statusBarBackground"/></declare-styleable>
<declare-styleable name="CoordinatorLayout_LayoutParams"><attr name="android:layout_gravity"/><attr format="string" name="layout_behavior"/><attr format="reference" name="layout_anchor"/><attr format="integer" name="layout_keyline"/><attr name="layout_anchorGravity"><flag name="top" value="0x30"/><flag name="bottom" value="0x50"/><flag name="left" value="0x03"/><flag name="right" value="0x05"/><flag name="center_vertical" value="0x10"/><flag name="fill_vertical" value="0x70"/><flag name="center_horizontal" value="0x01"/><flag name="fill_horizontal" value="0x07"/><flag name="center" value="0x11"/><flag name="fill" value="0x77"/><flag name="clip_vertical" value="0x80"/><flag name="clip_horizontal" value="0x08"/><flag name="start" value="0x00800003"/><flag name="end" value="0x00800005"/></attr></declare-styleable>
 <declare-styleable name="CollapsingToolbarLayout_Layout"><attr name="layout_collapseMode">

I'm using FloatingActionButton and TextInputLayout in one of my xml files

android-studio
asked on Stack Overflow Jun 28, 2019 by Henry O'Shea

1 Answer

0
AAPT: error: duplicate value for resource 'attr/layout_scrollFlags' with config ''.

AAPT: error: resource previously defined here.

AAPT: error: duplicate value for resource 'attr/behavior_peekHeight' with config ''.

AAPT: error: resource previously defined here.

AAPT: error: duplicate value for resource 'attr/layout_collapseMode' with config ''.

AAPT: error: resource previously defined here.

AAPT: error: duplicate value for resource 'attr/layout_anchorGravity' with config ''.

AAPT: error: resource previously defined here.

Try building your project again, because my error output stated only 2 duplicates.

This suggests that you've defined duplicate attributes in your values.xml file.

Here are some duplicates I found:

For layout_collapseMode:

<declare-styleable name="CollapsingAppBarLayout_LayoutParams">
    <attr name="layout_collapseMode">
        <enum name="none" value="0"/>
        <enum name="pin" value="1"/>
        <enum name="parallax" value="2"/>
    </attr>
    <attr format="float" name="layout_collapseParallaxMultiplier"/>
</declare-styleable>

and

<declare-styleable name="CollapsingToolbarLayout_Layout">
<attr name="layout_collapseMode"> <!--Why is this here??-->
<!--Should be like this:-->
<declare-styleable name="CollapsingToolbarLayout_Layout">
    <attr name="layout_collapseMode"/>
</declare-styleable>

For layout_anchorGravity: The new versions of ConstraintLayouts already define layout_anchorGravity

answered on Stack Overflow Jun 28, 2019 by SnakeException

User contributions licensed under CC BY-SA 3.0