嗨,开发人员,当我尝试执行应用程序时,我的Build Gradle存在问题我遇到了这些错误
Error:(114, 22) Failed to resolve: com.android.support.test.espresso:espresso-core:27.0.2
Error:(115, 22) Failed to resolve: com.android.support.test.espresso:espresso-intents:27.0.2
我的buildgradle是
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
flavorDimensions "1"
lintOptions {
checkReleaseBuilds true
lintConfig file("lint.xml")
}
defaultConfig {
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
signingConfigs{
release{
keyAlias 'your app name'
keyPassword 'key password'
storeFile file('location of your key file')
storePassword 'your keystore password'
}
}
productFlavors {
madani {
applicationId "com.herocode.quranreaderandroid"
}
}
buildTypes {
beta {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard.cfg'
signingConfig signingConfigs.release
versionNameSuffix "-beta"
if (project.hasProperty('disableCrashlytics')) {
ext.enableCrashlytics = false
}
}
debug {
ext.enableCrashlytics = false
applicationIdSuffix ".debug"
versionNameSuffix "-debug"
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard.cfg'
signingConfig signingConfigs.release
if (project.hasProperty('disableCrashlytics')) {
ext.enableCrashlytics = false
}
}
}
applicationVariants.all { variant ->
resValue "string", "authority", applicationId + '.data.QuranDataProvider'
resValue "string", "file_authority", applicationId + '.fileprovider'
if (applicationId.endsWith("debug")) {
mergedFlavor.manifestPlaceholders = [app_debug_label: "Quran " + flavorName.capitalize()]
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
testOptions.unitTests.all {
testLogging {
events 'passed', 'skipped', 'failed', 'standardOut', 'standardError'
outputs.upToDateWhen { false }
showStandardStreams true
exceptionFormat "full"
}
}
}
ext {
supportLibVersion = '27.0.2'
espressoVersion = '2.2.2'
}
dependencies {
compile 'com.android.support:support-v4:27.0.2'
compile 'com.android.support:appcompat-v7:27.0.2'
compile 'com.android.support:recyclerview-v7:27.0.2'
compile 'com.android.support:design:27.0.2'
compile 'io.reactivex.rxjava2:rxjava:2.0.4'
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
annotationProcessor 'com.google.dagger:dagger-compiler:2.8'
compile 'com.google.dagger:dagger:2.8'
compile 'com.squareup.okhttp3:okhttp:3.7.0'
compile 'com.squareup.moshi:moshi:1.3.1'
compile 'com.jakewharton.timber:timber:4.5.0'
compile 'com.jakewharton:butterknife:8.4.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
debugCompile 'com.facebook.stetho:stetho:1.4.1'
debugCompile 'com.facebook.stetho:stetho-okhttp3:1.4.1'
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5'
testCompile 'junit:junit:4.12'
testCompile 'com.google.truth:truth:0.30'
testCompile 'org.mockito:mockito-core:1.10.19'
testCompile 'com.squareup.okhttp3:mockwebserver:3.5.0'
androidTestCompile 'com.android.support.test.espresso:espresso-core:27.0.2'
androidTestCompile 'com.android.support.test.espresso:espresso-intents:27.0.2'
androidTestCompile 'com.android.support:support-annotations:27.0.2'
compile('com.crashlytics.sdk.android:crashlytics:2.6.6@aar') {
transitive = true
}
compile 'com.google.android.gms:play-services-ads:11.8.0'
}
项目构建就像
buildscript {
repositories {
google()
maven {
url "https://maven.google.com"
}
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'io.fabric.tools:gradle:1.22.1'
classpath 'me.tatarka:gradle-retrolambda:3.4.0'
classpath 'me.tatarka.retrolambda.projectlombok:lombok.ast:0.2.3.a2'
}
// Exclude the version that the android plugin depends on.
configurations.classpath.exclude group: 'com.android.tools.external.lombok'
}
allprojects {
repositories {
google()
maven {
url "https://maven.google.com"
}
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
}
答案 0 :(得分:2)
正确的依赖关系是:
androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.1'
androidTestCompile 'com.android.support.test:runner:1.0.1'
androidTestCompile 'com.android.support.test.espresso:espresso-intents:3.0.1'
选中此doumentation