gpt4 book ai didi

Android Studio 无法解析 Espresso 3.0.0

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:59:23 26 4
gpt4 key购买 nike

根据Android Espresso documentation迄今为止:

Add Espresso dependencies

To add Espresso dependencies to your project, complete the following steps:

  1. Open your app’s build.gradle file. This is usually not the top-level build.gradle file but app/build.gradle.
  2. Add the following lines inside 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'
}

我收到以下错误:

Error:(29, 24) Failed to resolve: com.android.support.test:runner:1.0.0
    Install Repository and sync project
Error:(30, 24) Failed to resolve: com.android.support.test.espresso:espresso-core:3.0.0
    Install Repository and sync project

我尝试点击“安装存储库和同步项目”链接,但没有任何反应。我也试过查看 SDK 管理器,但我真的看不到任何东西。

最佳答案

由于评论的解决方案正在解决问题,我将其添加为其他人的答案:

一定要加上Google's maven链接到主 build.gradle 文件:

allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}

关于Android Studio 无法解析 Espresso 3.0.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45455718/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com