2015-10-15 44 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
相关问题