4

I simply created a new project with android studio and as per the usage documentation for ActionbarSherlock added the two lines in my build.gradle.

My build.gradle looks like this:

buildscript {
 repositories {
        mavenCentral()
 }
 dependencies {
        classpath 'com.android.tools.build:gradle:0.6.+'
 }
}
apply plugin: 'android'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 18
    buildToolsVersion "18.1.1"

    defaultConfig {
        minSdkVersion 7
        targetSdkVersion 18
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:+'
    compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
    compile 'com.android.support:support-v4:18.0.+'
}

When I try to compile I get the following errors:

Compilation completed with 75 errors and 0 warnings in 14 sec
/Users/anthony/android/TestProject/Testqirc/build/exploded-
bundles/ComAndroidSupportAppcompatV71800.aar/res/values/values.xml
Gradle: Attribute "titleTextStyle" has already been defined
....
....
Gradle: Attribute "activityChooserViewStyle" has already been defined

changing the dependencies to

   dependencies {
    compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
    compile 'com.android.support:support-v4:18.0.+'
   }

I get this error:

Gradle: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'.

Anthony
  • 33,838
  • 42
  • 169
  • 278
  • 2
    You should use or ABS or appcompat. About last error - looks like your extending some theme from appcompat, or try clean re-build – Eugen Martynov Nov 19 '13 at 21:53

5 Answers5

3

See also Android 2.0 : Support Actionbar library (appcompat v7 support library without resources):No resource found @style/Theme.AppCompat.Light.DarkActionBar

The comment about using either ActionBarSherlock or AppCompat is correct; better to choose one or the other. If you've created the project using the New Project Wizard, then it's created a project that depends on AppCompat, and if you want to switch to ABS, you'll need to remove the dependencies by hand. That DarkActionBar is referenced from src/main/res/layout/fragment_main.xml.

Community
  • 1
  • 1
Scott Barta
  • 79,344
  • 24
  • 180
  • 163
0

You should remove this line :

compile 'com.android.support:support-v4:18.0.+'

Huy Tower
  • 7,769
  • 16
  • 61
  • 86
0

Make sure that you remove the default Theme.AppCompat.Light.DarkActionBar parent theme that is set on the project creation on your styles.xml file.

My styles.xml ended like this:

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.Sherlock.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    </style>

</resources>

And my build.gradle:

dependencies {
    compile 'com.android.support:support-v4:19.1.0'
    compile "com.actionbarsherlock:actionbarsherlock:4.4.0@aar"
}
AlexGuti
  • 3,063
  • 1
  • 27
  • 28
0

I ran into the same issue (duplicate Attributes) while attempting to get the Ultimate Stopwatch sample to import and build in Studio. Part of the work is figuring out (for my first time) how to import libraries into Studio (sort of off-topic - but there is a nice mellow video that demonstrates how to do this in Youtube (link below).

My bottom line - for some reason I added both the lines below to the build.gradle file for the ActionBarSherlock library:

dependencies {
    compile 'com.android.support:appcompat-v7:20.+'
    compile 'com.android.support:support-v4:20.+'
}

Turns out it appears that there already is a copy of ActionBarSherlock in the V7 support code - so you get dups. This worked for me - just pull out the V7 support:

dependencies {
    compile 'com.android.support:support-v4:20.+'
}

And here is the link to the procedure to add a library to Studio:

Youtube: How to Add Libraries to Android Studio by Mohammed Isa

https://www.youtube.com/watch?v=1MyBO9z7ojk

Cheers, Jim A

Jim Andreas
  • 1,557
  • 1
  • 17
  • 29
  • Oh and one more thing - you have to keep the V4 compat line as the ActionBarSherlock library apparently extends a V4 version of FragmentActivity in a file (here comes the pun) called "Watson.java". Cheers, – Jim Andreas Aug 27 '14 at 13:09
0

just update to latest version of play services and appcompat

https://stackoverflow.com/a/26588918/371749

Community
  • 1
  • 1
cV2
  • 5,229
  • 3
  • 43
  • 53