我遇到此错误:
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.
我不知道 values.xml 文件中有什么重复项。这里是提到的行:
<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">
我在我的一个xml文件中使用了 FloatingActionButton 和 TextInputLayout
答案 0 :(得分: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.
尝试再次构建项目,因为我的错误输出仅显示了2个重复项。
这表明您已经在values.xml
文件中定义了重复属性。
这是我发现的一些重复项:
对于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>
和
<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>
对于layout_anchorGravity
:
新版本的ConstraintLayouts已定义layout_anchorGravity