我试图将espresso链接到项目
我的错误
_MyProject:unspecified > com.android.support.test.espresso:espresso-core:2.0_
_> Could not find org.hamcrest:hamcrest-library:1.1._
在以下位置进行搜索:
C:/Users/username/AppData/Local/Android/sdk/extras/android/m2repository/org/hamcrest/hamcrest-library/1.1/hamcrest-library-1.1.jar _
无法找到编译Espresso
所需的其他库实际的Espresso库在这里,但是gradle看不到它
C:\ Users \用户名\应用程序数据\本地\的Android \ SDK \额外\机器人\ m2repository \ COM \机器人\支持\测试\浓咖啡
build.gradle文件包含:
buildscript {
repositories {
jcenter() // This is the default repo
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
}
}
apply plugin: 'com.android.application'
dependencies {
compile 'com.android.support:appcompat-v7:22.0.0'
compile fileTree(include: '*.jar', dir: 'libs')
provided fileTree(include: '*.jar', dir: 'ext_libs')
compile project(':third_party:facebook')
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.0'
androidTestCompile 'com.android.support.test:testing-support-lib:0.1'
}
我做错了什么?
答案 0 :(得分:1)
添加:
repositories {
mavenCentral();
}
到顶级build.gradle
(即,作为android
和dependencies
关闭的同行。
例如,在使用JUnit4的this sample project中(虽然不是Espresso),我有:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
}
}
apply plugin: 'com.android.application'
repositories {
mavenCentral() // required for testing-support-lib dependencies
}
dependencies {
androidTestCompile 'com.android.support.test:testing-support-lib:0.1'
}
android {
compileSdkVersion 19
buildToolsVersion "21.1.2"
defaultConfig {
testApplicationId "com.commonsware.android.gradle.hello.test"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
packagingOptions {
exclude 'LICENSE.txt' // required for no good reason...
}
}
答案 1 :(得分:0)
按照 CommonsWare 的建议添加了存储库关闭。现在很好。
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
}
}
apply plugin: 'com.android.application'
repositories {
mavenCentral() // required for testing-support-lib dependencies
}
答案 2 :(得分:0)
我也遇到了这个问题,并通过在"<<< userhome> \。gradle \ gradle.properties" Windows机器中的文件。
systemProp.ANDROID_HOME = C:\\android-sdk-windows