Q:

Implementing ActionBarSherlock, gradle error

I'm a starter at android developing and am currently really stuck with implementing actionbarsherlock. I know this has been discussed before, but I'm getting really confused regarding dependencies and how to set up the project structure. I tried following all the instructions, but it's not working out. I keep getting a different problem with the gradle. I'm using Android Studio 0.2.0.
My current error says:
>Gradle 'MyAppProject' project refresh failed:
>Could not fetch model of type 'IdeaProject' using Gradle distribution "http://services.gradle.org/distributions/gradle-1.6-bin.zip".
>Error: Gradle: A problem occurred configuring project ':MyApp'.
>Failed to notify project evaluation listener.
>A problem occurred configuring project ':Libraries:ActionBarSherlock'.
>Failed to notify project evaluation listener.
>Main Manifest missing from C:\Users\JJ2\AndroidStudioProjects\MyAppProject\Libraries\ActionBarSherlock\src\main\AndroidManifest.xml

My project is build as follows:
-MyAppProject
|+.idea
|+gradle
|-Libraries
||-ActionBarSherlock
|||+gen
|||+libs
|||+res
|||-src
||||-android.support.v4.app
|||||-Watson
||||+com.actionbarsherlock
|||-ActionBarSherlock.iml
|||-AndroidManifest.xml
|||-build.gradle
|||-lint.xml
|||-pom.xml
|||-project.properties
|||-README.md
|-MyApp
||+build
||+libs
||-src
|||-main
||||-java
|||||+com.mywebsite.myapp
||||+res
||||-AndroidManifest.xml
||||-ic_launcher-web.png
||-build.gradle
||-MyApp.iml
|-build.gradle
|-gradlew
|-gradlew.bat
|-local.properties
|-settings.gradle
|-MyAppProject.iml
-External Libraries
|-<Android 4.2.2>
||+android.jar
||+annotations.jar
||+res

The content of the build.gradle in the MyAppProject directory:
task assemble{}

The build.gradle in the MyApp directory:
buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.5.0'
    }
}
apply plugin: 'android'

dependencies {
    compile project(":Libraries:ActionBarSherlock")
}

android {
    compileSdkVersion 17
    buildToolsVersion "17.0.0"

    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 17
    }
}

And the build.gradle in the Libraries\ActionBarSherlock directory:
buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.5.0'
    }
}
apply plugin: 'android-library'

dependencies {
    compile files('libs/android-support-v4.jar')

}

android {
    compileSdkVersion 17
    buildToolsVersion "17.0.0"

    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 17
    }
}

Lastly, my Project Structure looks as follows:
Modules
-ActionBarSherlock (Dependencies: Android 4.2.2, [v]android-support-v4)
    -Android
-MyApp             (Dependencies: Android 4.2.2, [ ]ActionBarSherlock)
    -Android
    -Android-Gradle
-MyAppProject      (Dependencies: Android 4.2.2)
    -Android-Gradle

Libraries
None

Global Libraries
-android-support-v4 (Classes: ...\MyAppProject\MyApp\libs\android-support-v4.jar)

I hope somebody can notice anything wrong with the code, although a lot of people seem to have uresolved issues since the new Android Studio release.
Thanks in advance!

A:

Top directory settings.gradle:
include ':MyApp', ':Libraries:ActionBarSherlock'

include any other libs you may enter to your project
Top directory build.gradle:
its okay with task assemble {}
Actionbar sherlock build.gradle
buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.5.+'
    }
}
apply plugin: 'android-library'

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

android {
    compileSdkVersion 17
    buildToolsVersion "17.0.0"

    defaultConfig {
        minSdkVersion 7
        targetSdkVersion 16
    }
    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        instrumentTest.setRoot('tests')
    }
}

Also, IN ALL .gradle files that gradle version is set:
replace everywhere the gradle version to:
classpath 'com.android.tools.build:gradle:0.5.+'

Android Studio 2.x uses gradle 0.5.x, and by using + you 'll keep your gradle up to date (they updated it before 2 days, and we have frequent updates!! )
Your gradle settings now will be okay!
Note1:
Any other erros may occur from iml./idea files ... You can try changing them in Studio's project settings, eg set source files for each module(sherlock, MyApp), their libraries, etc!
Note 2:
Also if you are using some other libraries, which requires higher version of SDK than your app, you can get an error, w/o explanation!

