xml – Android Studio Error Duplicate Resource-ThrowExceptions

Exception or error:
Error:Execution failed for task ':fiesCabs:mergeDebugResources'. C:\Users\tony\AndroidstudioProjects\Fies-Cabs\fiesCabs\src\main\res\values\themes_apptheme.xml: Error: Duplicate resources: C:\Users\tony\AndroidstudioProjects\Fies-Cabs\fiesCabs\src\main\res\values\themes_apptheme.xml:style/AppTheme, C:\Users\tony\AndroidstudioProjects\Fies-Cabs\fiesCabs\src\main\res\values\styles.xml:style/AppTheme

Error:Error: Duplicate resources: C:\Users\tony\AndroidstudioProjects\Fies-Cabs\fiesCabs\src\main\res\values\themes_apptheme.xml:style/AppTheme, C:\Users\tony\AndroidstudioProjects\Fies-Cabs\fiesCabs\src\main\res\values\styles.xml:style/AppTheme

Error shown in android studio while building the project

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="Theme.AppCompat.Light">

<item name="android:editTextStyle">@style/EditTextAppTheme</item>

<item name="android:textColorHighlight">#9933b5e5</item>

<item name="android:autoCompleteTextViewStyle">@style/AutoCompleteTextViewAppTheme</item>

<item name="android:checkboxStyle">@style/CheckBoxAppTheme</item>

<item name="android:radioButtonStyle">@style/RadioButtonAppTheme</item>

<item name="android:buttonStyle">@style/ButtonAppTheme</item>

<item name="android:imageButtonStyle">@style/ImageButtonAppTheme</item>

<item name="android:spinnerStyle">@style/SpinnerAppTheme</item>

<item name="android:spinnerDropDownItemStyle">@style/SpinnerDropDownItemAppTheme</item>

<item name="android:progressBarStyleHorizontal">@style/ProgressBarAppTheme</item>

<item name="android:seekBarStyle">@style/SeekBarAppTheme</item>

<item name="android:ratingBarStyle">@style/RatingBarAppTheme</item>

<item name="android:ratingBarStyleIndicator">@style/RatingBarBigAppTheme</item>

<item name="android:ratingBarStyleSmall">@style/RatingBarSmallAppTheme</item>

<item name="android:buttonStyleToggle">@style/ToggleAppTheme</item>

<item name="android:listViewStyle">@style/ListViewAppTheme</item>

<item name="android:listViewWhiteStyle">@style/ListViewAppTheme.White</item>

<item name="android:spinnerItemStyle">@style/SpinnerItemAppTheme</item>

 </style>

</resources>

not familiar with android studio just imported the project from eclipse while it works fine with eclipse if there is any prerequisites to build in android studio please inform me

How to solve:

You have the same resource style/AppTheme in two files, values/styles.xml and values/themes_apptheme.xml. Rename or remove the other.

###

After using Android Studio to create a new empty Activity using the new Activity wizard, the layout’s XML file res/layout/myactivity_layout.xml was auto-generated, but Android Studio ALSO silently added /res/values/dimens.xml.

I already have a /res/values/dimen.xml file where I defined my various dimensions.

Android Studio added 2 new dimension keys to these files (without checking for conflicts) and sure enough, the keys for the 2 new dimensions were already defined in my dimen.xml file, so my Gradle build failed.

I assume the reason Android Studio added dimens.xml is because it didn’t recognize my dimen.xml file existed. And the reason Android Studio auto-added new dimensions to dimens.xml is to adhere to Android’s style conventions for Material Design (which I’m not adhering to for my project).

I would much prefer if Android Studio did not auto-generate problems without checking first!

I removed the extraneously added dimens.xml files and must now either rename my dimen.xml to dimens.xml or never use the new Activity Wizard again. Thanks Android.

Leave a Reply

Your email address will not be published. Required fields are marked *