2015-01-03 208 views
4

這我得到的錯誤:構建Android Studio項目時出現「錯誤:重複資源」?

: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> 

可能有人請解釋一下是什麼原因造成的錯誤,以及如何解決它?

UPDATE:

重複的資源在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">--> 
     <!--&lt;!&ndash; All customizations that are NOT specific to a particular API-level can go here. &ndash;&gt;--> 
    <!--</style>--> 


</resources> 

這似乎也讓我順利完成構建並解決問題。感謝您的評論@ pyus13

+0

好像你有AppTheme在你的styles.xml和themes_apptheme.xml請包括有問題的bith文件的內容。 – pyus13

+0

這就是問題所在......感謝您的幫助。 – Vedant261

回答

2

變量Apptheme兩個themes_apptheme.xmlstyles.xml不能保持相同的名稱,因爲在Appthemethemes_apptheme.xmlstyles.xml反正。 只要刪除其中一個修改它

相關問題