&引用;错误:重复资源“;在构建Android Studio项目时?
这就是我得到的错误:&引用;错误:重复资源“;在构建Android Studio项目时?,android,xml,android-gradle-plugin,Android,Xml,Android Gradle Plugin,这就是我得到的错误: :app:mergeDebugResources :app:mergeDebugResources FAILED /Users/vedantdasswain/GitRepositories/EnergyLens/AndroidStudioVersion/EnergyLens/app/src/main/res/values/themes_apptheme.xml Error:Error: Duplicate resources: /Users/vedantdasswain/G
:app:mergeDebugResources
:app:mergeDebugResources FAILED
/Users/vedantdasswain/GitRepositories/EnergyLens/AndroidStudioVersion/EnergyLens/app/src/main/res/values/themes_apptheme.xml
Error:Error: Duplicate resources: /Users/vedantdasswain/GitRepositories/EnergyLens/AndroidStudioVersion/EnergyLens/app/src/main/res/values/themes_apptheme.xml:style/AppTheme, /Users/vedantdasswain/GitRepositories/EnergyLens/AndroidStudioVersion/EnergyLens/app/src/main/res/values/styles.xml:style/AppTheme
Error:Execution failed for task ':app:mergeDebugResources'.
> /Users/vedantdasswain/GitRepositories/EnergyLens/AndroidStudioVersion/EnergyLens/app/src/main/res/values/themes_apptheme.xml: Error: Duplicate resources: /Users/vedantdasswain/GitRepositories/EnergyLens/AndroidStudioVersion/EnergyLens/app/src/main/res/values/themes_apptheme.xml:style/AppTheme, /Users/vedantdasswain/GitRepositories/EnergyLens/AndroidStudioVersion/EnergyLens/app/src/main/res/values/styles.xml:style/AppTheme
此错误的来源是以下文件themes_apptheme.xml:
<?xml version="1.0" encoding="utf-8"?>
<!-- Generated with http://android-holo-colors.com -->
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="AppTheme" parent="@style/_AppTheme"/>
<style name="_AppTheme" parent="android:Theme.Holo.Light">
<item name="android:editTextBackground">@drawable/apptheme_edit_text_holo_light</item>
<item name="android:textColorHighlight">#99003366</item>
<item name="android:textSelectHandleLeft">@drawable/apptheme_text_select_handle_left</item>
<item name="android:textSelectHandleRight">@drawable/apptheme_text_select_handle_right</item>
<item name="android:textSelectHandle">@drawable/apptheme_text_select_handle_middle</item>
<item name="android:autoCompleteTextViewStyle">@style/AutoCompleteTextViewAppTheme</item>
<item name="android:listChoiceIndicatorMultiple">@drawable/apptheme_btn_check_holo_light</item>
<item name="android:listChoiceIndicatorSingle">@drawable/apptheme_btn_radio_holo_light</item>
<item name="android:buttonStyle">@style/ButtonAppTheme</item>
<item name="android:imageButtonStyle">@style/ImageButtonAppTheme</item>
<item name="android:dropDownSpinnerStyle">@style/SpinnerAppTheme</item>
<item name="android:listChoiceBackgroundIndicator">@drawable/apptheme_list_selector_holo_light</item>
<item name="android:activatedBackgroundIndicator">@drawable/apptheme_activated_background_holo_light</item>
<item name="android:fastScrollThumbDrawable">@drawable/apptheme_fastscroll_thumb_holo</item>
</style>
</resources>
@可绘制/应用主题\编辑\文本\全息\灯光
#99003366
@可绘制/应用主题\文本\选择\句柄\左侧
@可绘制/应用主题\文本\选择\句柄\右键
@可绘制/应用主题\文本\选择\句柄\中间
@样式/自动完成TextViewAppTheme
@可绘图/应用主题\u btn\u检查\u全息灯
@可拖动/应用主题\u btn\u收音机\u全息灯
@风格/主题
@样式/图像主题
@风格/主题
@可绘制/应用主题列表选择器全息灯
@可绘制/应用主题\激活\背景\全息灯
@可绘制/应用主题\快速卷轴\拇指\全息
有人能解释一下是什么导致了这个错误以及如何解决它吗
更新:
styles.xml中提到了重复资源,我对此进行了注释:
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<!--<style name="AppTheme" parent="AppBaseTheme">-->
<!--<!– All customizations that are NOT specific to a particular API-level can go here. –>-->
<!--</style>-->
</resources>
这似乎让我成功地完成了构建并解决了问题。感谢您在
themes\u Apptheme.xml
和styles.xml
中对@pyus13变量Apptheme
的评论,因为themes\u Apptheme.xml
中的Apptheme
指的是styles.xml
。
只需删除或修改其中一个即可。您的styles.xml和themes中似乎都有AppTheme\u AppTheme.xml请包含有问题的bith文件的内容。