26

I have imported an eclipse android project into android studio 1.2.2 The gradle of my project:

dependencies {
    compile project(':unifiedPreferenceLib')
    compile project(':viewPagerIndicatorLib')
    compile project(':slidingUpFourSquare')
    compile project(':stylishDialogLib')
    compile project(':swipeListViewLib')
    compile project(':library')
    compile project(':textDrawLib')
    compile project(':cardview')
    compile project(':editTextFormLibrary')
    compile 'com.android.support:support-v4:22.2.0'
    compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
    compile 'com.google.android.gms:play-services:+'
    compile files('libs/CWAC-LocationPoller.jar')
    compile files('libs/Parse-1.8.0.jar')
    compile files('libs/ParseCrashReporting-1.8.0.jar')
    compile files('libs/android-support-v13.jar')
    compile files('libs/blurnavdrawerlib.jar')
    compile files('libs/bolts-android-1.1.4.jar')
    compile files('libs/google-http-client-1.15.0-rc.jar')
    compile files('libs/google-http-client-android-1.15.0-rc.jar')
    compile files('libs/google-http-client-jackson2-1.15.0-rc.jar')
    compile files('libs/loremipsum-1.0.jar')
    compile files('libs/splunk-mint-4.0.8.jar')
    compile files('libs/textdrawlib.jar')
}

I am getting

Error:(1) Attribute "titleTextStyle" has already been defined

pointing to my colors.xml but my xml file does not even have this element with such an attribute.

Zoe
  • 27,060
  • 21
  • 118
  • 148
Nezam
  • 4,122
  • 3
  • 32
  • 49

1 Answers1

29

The problem is 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar' defines the attribute titleTextStyle which is also defined in another library, thus the conflict rises.

Other people have had the same problem with Action Bar Sherlock after adding it(here and here) where appcompat-v7 already had an actionbar with the same functionality (same titleTextStyle attribute as well). Using ActionBar from appcompat-v7 over ActionBarSherlock was recommended.

In your case appcompat v7 isn't directly added as a dependency however

As described in this answer

The last version of Google Play Services now uses appcompat-v7, so u can't use it with actionbarsherlock. You have to use only appcompat-v7 or the previous version of play services:

compile 'com.google.android.gms:play-services:7.0.0'

You were using the latest so the conflict appearead. You could, as suggested, use only appcompat or stick to actionbarsherlock and switch to playservices version 7.0.0.

Looking over the android support library features i noticed they guide you to:

In general, we recommend including the v4 support and v7 appcompat libraries, because they support a wide range of Android versions and provide APIs for recommended user interface patterns.

which is another indication as not to use actionbarsherlock.

Community
  • 1
  • 1
Laurentiu L.
  • 6,566
  • 1
  • 34
  • 60
  • I already solved this issue by removing actionBarSherlock library altogether. A particular library project which i have been using depended upon actionbarsherlock. I tweaked this library to compile without the need for actionbarsherlock. Anyway what you say seem the right way to go. So awarding you unless someone else has a better answer. – Nezam Aug 20 '15 at 17:41
  • 1
    What if I do need to use 2 libraries that define attributes of specific views, using declare-styleable , yet even though the views have a different package, the attributes names are the same? How can I handle this? – android developer Dec 16 '15 at 12:35
  • @androiddeveloper this seems like a broad enough problem for many users to encounter thus deserving it's own question. This question alone has had numerous hits in the last 2 months. I suggest you post your question separately, I will answer when I get the time to, unless someone else provides a relevant answer before that. Cheers! – Laurentiu L. Dec 16 '15 at 12:39
  • 2
    compiling 'com.google.android.gms:play-services:7.0.0' solved the problem, thanks! – Serdar Samancıoğlu Mar 21 '16 at 08:28