Qui*_*don 5 dependencies android android-espresso
根据迄今为止的Android Espresso文档:
添加Espresso依赖项
要将Espresso依赖项添加到项目中,请完成以下步骤:
- 打开应用程序的build.gradle文件.这通常不是顶级的build.gradle文件,而是app/build.gradle.
- 在依赖项中添加以下行:
androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.0'
androidTestCompile 'com.android.support.test:runner:1.0.0'
Run Code Online (Sandbox Code Playgroud)
我创建了一个新项目,生成的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'
}
Run Code Online (Sandbox Code Playgroud)
当我将其更改为以下内容时:
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'
}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
错误:(29,24)无法解决:com.android.support.test:runner:1.0.0
安装存储库和同步项目
错误:(30,24)无法解决:com.android.support.test.espresso: espresso-core:3.0.0
安装存储库和同步项目
我试过点击"安装存储库和同步项目"链接但没有任何反应.我也尝试过查看SDK管理器,但我真的看不到任何东西.
R. *_*ski 12
由于评论的解决方案正在解决问题,我将其作为其他人的答案添加:
请务必将Google的maven链接添加到主build.gradle文件:
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10648 次 |
| 最近记录: |