根据Android Espresso文档,迄今为止:
我创建了一个新项目,生成的 app/gradle 文件如下所示:
当我将它改为以下内容时:
我遇到了以下错误:
添加Espresso依赖项
要将Espresso依赖项添加到您的项目中,请完成以下步骤:
- 打开应用程序的build.gradle文件。这通常不是顶级build.gradle文件,而是app/build.gradle。
- 在dependencies内添加以下行:
androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.0'
androidTestCompile 'com.android.support.test:runner:1.0.0'
我创建了一个新项目,生成的 app/gradle 文件如下所示:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.app.test"
minSdkVersion 24
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
testCompile 'junit:junit:4.12'
}
当我将它改为以下内容时:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.app.test"
minSdkVersion 24
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:26.+'
testCompile 'junit:junit:4.12'
// App's dependencies, including test
compile 'com.android.support:support-annotations:22.2.0'
// Testing-only dependencies
androidTestCompile 'com.android.support.test:runner:1.0.0'
androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.0'
}
我遇到了以下错误:
我尝试点击“安装存储库并同步项目”链接,但没有任何反应。我也尝试在SDK管理器中查找,但看不到任何东西。Error:(29, 24) Failed to resolve: com.android.support.test:runner:1.0.0
安装存储库并同步项目
Error:(30, 24) Failed to resolve: com.android.support.test.espresso:espresso-core:3.0.0
安装存储库并同步项目