Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio Error Duplicate Resource

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

like image 302
tom030888 Avatar asked Apr 08 '15 07:04

tom030888


People also ask

How to solve error duplicate resources in Android studio?

It happens because the initial icon still exists and with the same name inside the mipmap folder. the solution for me was to delete the initial launcher icon. Solution: Change your view to Project, find the initial icon, and delete it, then the error should be gone.

How do I resolve duplicate resources in Android?

Remove the files you might have on: android/app/src/main/res/drawable-mdpi/ android/app/src/main/res/drawable-xhdpi/ android/app/src/main/res/drawable-xxhdpi/ Run Build again, This fixed the issue for me.

Where is the style XML?

Defining Styles This XML file resides under res/values/ directory of your project and will have <resources> as the root node which is mandatory for the style file. The name of the XML file is arbitrary, but it must use the . xml extension.


2 Answers

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

like image 146
laalto Avatar answered Sep 27 '22 19:09

laalto


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.

like image 37
rmirabelle Avatar answered Sep 27 '22 19:09

rmirabelle