Re: Cannot resolve external maven dependencies with gradle / android studio

5,827 views
Skip to first unread message

Xavier Ducrohet

unread,
May 21, 2013, 8:24:02 PM5/21/13
to adt...@googlegroups.com
you're missing 

repositories {
   mavenCentral() 
}

The one present in buildscript {} is only for configuring the classpath of the build, not for your own project. you need to add it (outside of buildscript {})


On Tue, May 21, 2013 at 4:07 PM, Traun Leyden <traun....@gmail.com> wrote:

I'm not able to resolve external dependencies using gradle.  I've created a brand new project, and edited the gradle.build file to be as follows:

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

dependencies {
    compile files('libs/android-support-v4.jar')
    compile 'com.google.guava:guava:11.0.2'
}

android {
    compileSdkVersion 17
    buildToolsVersion "17.0.0"

    defaultConfig {
        minSdkVersion 7
        targetSdkVersion 16
    }
}

(the only change from the default: I added compile 'com.google.guava:guava:11.0.2' to dependencies, which is from this example)

When I run $ ./gradlew dependencies or ./gradlew build, I get this error:

The TaskContainer.add() method has been deprecated and is scheduled to be removed in Gradle 2.0. Please use the create() method instead.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':DepsTest'.
> Failed to notify project evaluation listener.
   > Could not resolve all dependencies for configuration ':DepsTest:compile'.
      > Could not find com.google.guava:guava:11.0.2.
        Required by:
            DepsTest:DepsTest:unspecified

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Am I doing something wrong?  Should I file a bug?

--
You received this message because you are subscribed to the Google Groups "adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adt-dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Xavier Ducrohet
Android SDK Tech Lead
Google Inc.
http://developer.android.com | http://tools.android.com

Please do not send me questions directly. Thanks!

Traun Leyden

unread,
May 21, 2013, 8:28:40 PM5/21/13
to adt...@googlegroups.com

That fixed it, thanks!

Here's my new build.gradle:

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

repositories {
    mavenCentral()

Xavier Ducrohet

unread,
May 22, 2013, 12:33:52 PM5/22/13
to adt...@googlegroups.com
We are not going to add this automatically for you. It's up to you to know which repositories you want to dowload from.


On Wed, May 22, 2013 at 8:06 AM, Sergey Chuvashev <sergey.c...@gmail.com> wrote:
whether it will be added in the next versions of Android studio?

среда, 22 мая 2013 г., 4:24:02 UTC+4 пользователь Xavier Ducrohet написал:

Sergey Chuvashev

unread,
May 23, 2013, 4:44:42 PM5/23/13
to adt...@googlegroups.com
Thanks for you reply.

I mean "automatically add dependencies to the project classpath, not ony the build classpath". With repositories I understanв you, that is right.

среда, 22 мая 2013 г., 20:33:52 UTC+4 пользователь Xavier Ducrohet написал:
Reply all
Reply to author
Forward
0 new messages