[英]Gradle could not resolve otto library
I try to embed Otto library, which exists at the 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'
}
But I get the exception: 但是我得到了例外:
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
I tried to refresh dependencies( gradle --refresh-dependencies
) but it doesn't help. 我试图刷新依赖项( gradle --refresh-dependencies
),但它没有帮助。
You need to tell gradle where to find it. 你需要告诉gradle在哪里找到它。
repositories {
mavenCentral()
}
Note that the existing repositories { ... }
inside buildscript { ... }
is only to configure the repositories for the build classpath itself, not your project, so put this new element just under apply plugin ...
请注意, buildscript { ... }
中的现有repositories { ... }
仅用于构建构建类路径本身的存储库,而不是您的项目,因此请将此新元素放在apply plugin ...
I believe what you're missing is Tools->Android->Sync Project with Gradle Files
. 我相信你所缺少的是Tools->Android->Sync Project with Gradle Files
。 I tested your code above and it worked just fine for me. 我在上面测试了你的代码,它对我来说效果很好。
Hope this helps. 希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.