2015-10-15 113 views
2

我在android studio中創建新項目時遇到了這個錯誤,我已經檢查過這個庫並且有hamcrest-core-1.3.jar文件。請幫助我如何在android studio中創建新項目時解決hamcrest jar文件錯誤

Error:A problem occurred configuring project ':app'. 
    > Could not download hamcrest-core.jar (org.hamcrest:hamcrest-core:1.3) 
    > Could not get resource 'https://jcenter.bintray.com/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar'. 
    > Could not GET 'https://jcenter.bintray.com/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar'. 
    > jcenter.bintray.com 

回答

6

錯誤不是因爲hamcrest-core-1.3.jar文件。似乎gradle無法連接到jcenter並下載junit.jar。因此,確保您的互聯網連接並重建您的項目。通常Gradle會下載所有必需的罐子。如果它嘗試更新你的構建工具。

0

以我的經驗,當我創造了我遇到過這個問題一個新的項目。 要解決它,我從build.gradle模塊中刪除了依賴關係:app。

testCompile 'junit:junit:4.12' 

之後,重建項目的問題從未發生過。

1

取下的build.gradle模塊下面幾行:應用程序下依賴

androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.1', { 
     exclude group: 'com.android.support', module: 'support-annotations' 
    }) 
+0

這將是很好的補充,爲什麼刪除這些線路將有助於 –

+0

這其實真的制定了我一個解釋。獎勵!但爲什麼呢?這背後有解釋嗎? –

0

我以前有同樣的問題,gradle這個無法訪問我的情況罐子庫。

你可能需要:

  1. 首先確保您連接到互聯網
  2. 安裝Android Studio中(特別是如果你使用它從你的工作環境/網絡)的代理設置或連接到一個開放的網絡
0

轉到gradle.properties和評論都systemProp proxys並重新同步

它的工作對我來說

  • 的Android 2.3.3
相關問題