Gradle无法解析otto库

ele*_*ven 3 dependencies android repository gradle maven-central

我尝试嵌入位于Maven Central的Otto库.

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

    }
}

apply plugin: 'android'

dependencies {
    compile 'com.google.android.gms:play-services:4.0.30'
    compile 'com.android.support:support-v13:19.0.0'
    compile 'com.squareup:otto:1.3.4'
}
Run Code Online (Sandbox Code Playgroud)

但是我得到了例外:

A problem occurred configuring root project 'sample-project'.
> Failed to notify project evaluation listener.
   > Could not resolve all dependencies for configuration ':_DebugCompile'.
      > Could not find com.squareup:otto:otto:1.3.4.
        Required by:
            :sample-project:unspecified
Run Code Online (Sandbox Code Playgroud)

我试图刷新依赖项(gradle --refresh-dependencies)但它没有帮助.

Xav*_*het 10

你需要告诉gradle在哪里找到它.

repositories {
    mavenCentral()
}
Run Code Online (Sandbox Code Playgroud)

请注意,现有的repositories { ... }内部buildscript { ... }只是为构建类路径本身而不是项目配置存储库,所以将这个新元素放在下面apply plugin ...