Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.
like image 639
Chad Bingham Avatar asked Oct 29 '13 19:10

Chad Bingham


2 Answers

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

like image 197
Adam Johns Avatar answered Sep 25 '22 03:09

Adam Johns


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.

like image 29
Adam Morgan Avatar answered Sep 24 '22 03:09

Adam Morgan