6

I am trying to add ActionBarSherlock to my existing app. This is not as easy as I thought. I have been doing this for two days now. I have tried every tutorial for 2 pages of Google results. Here is what I have after following this tutorial.

My project Structure

enter image description here

ActionBarSherlock/actionbarsherlock/ build.gradle

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

repositories {
  mavenCentral()
}

dependencies {
  compile 'com.android.support:support-v4:13.0.+'
  compile files('libs/Parse-1.3.1.jar')
}
android {
  sourceSets {
    main {
      manifest.srcFile 'src/main/AndroidManifest.xml'
    }
  }
}
android {
  compileSdkVersion 17
  buildToolsVersion "17.0.0"

  defaultConfig {
    minSdkVersion 7
    targetSdkVersion 16
  }
}

ClashMMAProject/ClashMMA/ build.gradle

  buildscript {
repositories {
    maven { url 'http://repo1.maven.org/maven2' }
}
dependencies {
    classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'

repositories {
mavenCentral()
 }

dependencies {
compile 'com.android.support:support-v4:13.0.+'
compile files('libs/Parse-1.3.1.jar')
compile project(':libraries:ActionBarSherlock:actionbarsherlock')
 }
android {
sourceSets {
    main {
        manifest.srcFile 'src/main/AndroidManifest.xml'
    }
}
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"

defaultConfig {
    minSdkVersion 7
    targetSdkVersion 16
}
}

setting.gradle

include ':ClashMMA', ':libraries:ActionBarSherlock:actionbarsherlock'

Dependancies

enter image description here

My Error

enter image description here

I have done a lot of research and I can't get anything to work. I get an error every time, so there is something I don't understand correctly. Please help. Thanks for your time.


Update

Ok after the suggestions, this is what I have in ClashMMAProject/ClashMMA/ build.gradle

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

repositories {
mavenCentral()
}

dependencies {
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
compile 'com.android.support:support-v4:18.0.+'
compile files('libs/Parse-1.3.1.jar')
}
android {
sourceSets {
    main {
        manifest.srcFile 'src/main/AndroidManifest.xml'
    }
}
}
android {
compileSdkVersion 17
buildToolsVersion "18.0.1"

defaultConfig {
    minSdkVersion 7
    targetSdkVersion 16
}
}

This is producing an error:

Gradle: Execution failed for task ':ClashMMA:processDebugManifest'.
        > Manifest merging failed. See console for more info.
Chad Bingham
  • 32,650
  • 19
  • 86
  • 115
  • Are you committed to ABS or could you use the ActionBar via the [recently updated support library](http://developer.android.com/guide/topics/ui/actionbar.html)? – blahdiblah Oct 29 '13 at 19:17
  • No I am open to either. I tried ActionBar and got the same error as this guy, and couldnt find an answer. http://stackoverflow.com/questions/19417666/cant-import-actionbarcompat-from-android-support-library-using-android-studio – Chad Bingham Oct 29 '13 at 19:19

2 Answers2

9

I also struggled with this, as it seemed every tutorial or answer I followed left some small detail out that a beginner doesn't know as something to automatically do. Here is how I eventually got ABS added to my project:

1.Don't download ABS at all. You can completely add it by modifying your existing build.gradle file. Not your project's build.gradle, but your inner folder that is the parent folder of your src directory.

2.Open SDK Manager and make sure you have Android SDK Build-tools 18.0.1 (later versions might also work).

3.Model your build.gradle file after mine. This is the exact build.gradle file I am using that works. Make sure your minSdk and targetSdk match what is in your manifest:

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

repositories {
    mavenCentral()
}

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

android {
    compileSdkVersion 18
    buildToolsVersion "18.0.1"

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 18
    }
}

4.Make sure you are using gradle 1.8 in gradle-wrapper.properties:

distributionUrl=http\://services.gradle.org/distributions/gradle-1.8-bin.zip

5.Sync project with gradle files by pressing the button:

enter image description here

Adam Johns
  • 35,397
  • 25
  • 123
  • 176
  • Make sure you are using gradle 1.8 in gradle-wrapper.properties -- What do you mean by this? – Chad Bingham Oct 29 '13 at 21:08
  • 1
    Open the file gradle-wrapper.properties and in the distributionUrl, if it already specifies gradle-1.8-bin.zip then you are good. If it says something like gradle-1.6-bin.zip then literally just change the 6 to an 8. – Adam Johns Oct 29 '13 at 21:10
  • change in file named gradle-wrapper.properties – Adam Johns Oct 29 '13 at 21:11
  • as mentioned [here](http://stackoverflow.com/questions/17587751/gradle-execution-failed-for-task-processdebugmanifest) make sure your minsdk and targetsdk in build.gradle match your minsdk and targetsdk in androidmanifest.xml – Adam Johns Oct 29 '13 at 21:21
  • also, your compile sdk version might need to be same as target sdk. I'm not sure on that. – Adam Johns Oct 29 '13 at 21:22
  • Was the problem that your sdk versions didn't match android manifest or that compilesdkversion didn't match targetsdkversion? – Adam Johns Oct 29 '13 at 21:29
  • I've found that just sync'ing the project or closing/reopening will tell gradle to fetch the dependencies. The same issue happened to me a while back and that fixed it. – Eric Barr Oct 29 '13 at 23:05
3

The ActionBarSherlock author has provided a .aar file, so you will no longer need to build the library that you have in your libraries folder. You can change your build.gradle to be something like:

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

repositories {
  mavenCentral()
}

dependencies {
  compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
  compile 'com.android.support:support-v4:13.0.+'
  compile files('libs/Parse-1.3.1.jar')
}
android {
  sourceSets {
    main {
      manifest.srcFile 'src/main/AndroidManifest.xml'
    }
  }
}
android {
  compileSdkVersion 17
  buildToolsVersion "17.0.0"

  defaultConfig {
    minSdkVersion 7
    targetSdkVersion 16
  }
}

Note the actionbarsherlock aar file in dependencies, and the removal of the library dependency. (I also see that your gradle is at 0.5.+ and your buildToolsVersion is at "17.0.0", the most recent versions are 0.6.+ and "18.1.1", but you can work on those once ABS is working for you).

Now you can safely remove your libraries/ActionBarSherlock, which you will no longer need, and change your settings.gradle file to:

include ':ClashMMA'

Hope this helps.

  • I would try using the command line `gradle assembleDebug --info`. Check out [this question](http://stackoverflow.com/questions/17587751/gradle-execution-failed-for-task-processdebugmanifest) – Adam Morgan Oct 29 '13 at 22:28