error: Attribute "***" has already been defined when using two library projects in Android
Asked Answered
D

5

19

I'm using android-support-v7-appcompat as a library in my Android project. Now I want to include actionbarsherlock as another library project. When I add the second library, it gives so many errors like below

android-support-v7-appcompat\res\values\attrs.xml:476: error: Attribute "attributeName" has already been defined

By changing one attribute value and it's related code snippet is a one solution that I've tried. But when there are nearly 80 lines like above, it will get a messy. Is there any other way I can solve this issue?

Desjardins answered 15/11, 2013 at 7:44 Comment(1)
This is not the answer. But in my case I have used above both libraries to get the ActionBar features. So I have removed android-support-v7-appcompat and continued.Desjardins
D
9

The correct way to solve this problem is by updating Android Support Libraries in all relevant projects and library projects. In my case I've used Android support library and also one of the library project to implement my application. When I update both libraries, the problem solved. The way of updating Android support library is;

  • Right click on the project
  • Select Android Tools from the pop up window
  • Select Add Support Library
Desjardins answered 29/1, 2014 at 8:55 Comment(2)
This doesn't work for me. I'm trying the exact same thing as AnujAroshA - using android-support-v7-appcompat as a library as well as ActionBarSherlock. I get the same error. I've updated the support libraries like you've suggested (and this I knew), and then cleaned all three projects. No luck.Penang
How can I update the library I am importing? It is just a 'compile "libraryhere"' statement.Egmont
U
3

Remove the appcompact support library project from Properties = > Android

Unshakable answered 21/9, 2014 at 7:6 Comment(0)
P
3

Gradle Resource Merger merges all resource folders from all dependencies and place into single folder. In case there are duplicates build process will fail.

Fortunately, if you look below under Output: label, you will find the right path to the problem.

Here is an example

enter image description here

in your case it is android-support-v7-appcompat\res\values\attrs.xml:476: error: Attribute "attributeName" has already been defined

You can also build your project from command line and get the right path. attributeName Inside values\attrs.xml file on line 476 you would find a with property named "attributeName". Most probably it is your own styleable that you have to change to get rid of the duplicate.

So now, when you know the reason, you can locate that property in your project module and replace it with different name.

Paulson answered 14/7, 2015 at 13:37 Comment(0)
I
1

I solved this by removing appcompact from project, and changing in styles to

<style name="AppBaseTheme" parent="Theme.Sherlock">
Iolanthe answered 30/4, 2014 at 10:47 Comment(0)
A
0

I updated the build tools version and resynced, it worked fine.

Atelectasis answered 8/2, 2017 at 21:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.