skhizein
skhizein

Reputation: 437

android studio adding library

I am adding to my project actionbarsherlock library on android studio.

I create libs folder and added actionsherlock bar library codes and other jar file for slidingmenu. build.grandle file of my project:

buildscript {

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

repositories { mavenCentral() }

android { compileSdkVersion 18 buildToolsVersion "17.0.0"

defaultConfig {
    minSdkVersion 7
    targetSdkVersion 16
} }


dependencies {
    compile files('libs/library')
    compile project(':libs:actionbarsherlock')

}

setttings.grandle file of my project

include':MyProject',':libs:actionbarsherlock'

And I am getting this error on runtime:

Gradle: A problem occurred configuring project ':MyProject'.

Failed to notify project evaluation listener. Configuration with name 'default' not found.

Thanks for help

Upvotes: 0

Views: 114

Answers (2)

Akshay GS
Akshay GS

Reputation: 93

Replace "apply plugin: 'android'" with "apply plugin: 'com.android.library'"

and add this on top of in the gradle file.

Upvotes: 0

Scott Barta
Scott Barta

Reputation: 80020

I'm not sure if the buildfile as it appears in your question is exact or if the formatting is messed up from pasting it into the web form, but some things need to be on separate lines for the script to work. For example,

compileSdkVersion 18 buildToolsVersion "17.0.0"

will cause an error.

A couple other things I see:

Use 0.6 or later for the Gradle plugin.

Instead of downloading ActionBarSherlock as a source library, use a Maven-style dependency to have Gradle pull the AAR directly from a Maven repository. This is easier and works better. If I use this build file I don't see your error:

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

apply plugin: 'android'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 18
    buildToolsVersion '17.0.0'

    defaultConfig {
        minSdkVersion 7
        targetSdkVersion 16
    }
}

dependencies {
    compile files('libs/library')
    compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
}

If you're still having problems, please build from the command line with the --info and --stacktrace options and paste the output into your question.

Upvotes: 0

Related Questions