2016-08-03 433 views
0

試圖添加兩個maven倉庫,但似乎無法得到解決。
找不到計算器上的任何信息,並想知道什麼是在搖籃解決依賴的標準方式無法解決:de.hdodenhof:circleimageview:2.1.0

根的build.gradle

buildscript { 
    repositories { 
     mavenCentral() 
//  maven { url "https://mvnrepository.com/artifact/de.hdodenhof/circleimageview" } 
     jcenter() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:2.1.2' 

     // NOTE: Do not place your application dependencies here; they belong 
     // in the individual module build.gradle files 
    } 
} 

模塊的build.gradle

dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    testCompile 'junit:junit:4.12' 
    compile 'com.android.support:appcompat-v7:23.3.0' 
// compile files('libs/CircleImageView-master/gradle/wrapper/gradle-wrapper.jar') 
    compile 'de.hdodenhof:circleimageview:2.1.0' 
} 

失敗要解決:de.hdodenhof:circleimageview:2.1.0

回答

0

您是否已將compile依賴項添加到r ight Gradle文件?確保compile 'de.hdodenhof:circleimageview:2.1.0'行位於dependencies {}塊中,並且該塊位於模塊文件夾中的build.gradle文件中,而不在項目的根目錄中。

如果沒有幫助,請嘗試從命令行運行./gradlew clean --refresh-dependencies

+0

是的,根gradle具有存儲庫,並且模塊gradle具有依賴關係。我已更新了我的主帖。 我已經使用Android Studio中的乾淨版本,我相信它相當於gradlew clean,但只要我想清楚,就會嘗試使用它。 –

+0

不,它不相似,因爲'--refresh-dependencies'使Gradle緩存無效並強制再次下載所有依賴項。 –

+0

應該在Android Studio或外部運行 –

1

我可以下載該問題中寫入的依賴關係。不過,作爲參考,這裏是我的項目的build.gradle。我認爲你需要allprojects一塊。如果沒有這些依賴關係,我就會遇到問題。

buildscript { 
    repositories { 
     jcenter() 
     mavenCentral() 
     mavenLocal() 
    } 

    dependencies { 
     classpath 'com.android.tools.build:gradle:2.1.2' 

     // NOTE: Do not place your application dependencies here; they belong 
     // in the individual module build.gradle files 
    } 
} 

allprojects { 
    repositories { 
     jcenter() 
     mavenCentral() 
     mavenLocal() 
    } 
} 

額外的說明:如果你是編譯克隆回購,你做這樣的事情

dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    compile project(":CircleImageView-master:circleimageview") 

    ... 
} 

凡settings.gradle將有

include ':app', ':CircleImageView-master:circleimageview' 
+1

剛剛意識到問題與依賴關係無關,但與我的代理有關,因爲我能夠在連接到我的WiFi熱點時編譯依賴關係,而不是公司代理 –