Search code examples
androidactionbarsherlockandroid-studio

Adding ActonBarSherlock in Android Studio


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.

Solution

  • 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