簡體   English   中英

Gradle無法解析otto庫

[英]Gradle could not resolve otto library

我嘗試嵌入位於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'
}

但是我得到了例外:

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

我試圖刷新依賴項( gradle --refresh-dependencies ),但它沒有幫助。

你需要告訴gradle在哪里找到它。

repositories {
    mavenCentral()
}

請注意, buildscript { ... }中的現有repositories { ... }僅用於構建構建類路徑本身的存儲庫,而不是您的項目,因此請將此新元素放在apply plugin ...

我相信你所缺少的是Tools->Android->Sync Project with Gradle Files 我在上面測試了你的代碼,它對我來說效果很好。

希望這可以幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM