错误:尝试添加多个依赖项时无法解决:com.android

时间:2019-06-23 11:16:10

标签: android gradle

我现在正在学习1.5岁的Udemy指南,该指南刚刚购买了各种先进的android设备。我到了需要加载一堆第三方库的地步,所以我按照指南进行操作,并得到以下错误提示:


ERROR: Failed to resolve: com.android
Affected Modules: app


WARNING: The specified Android SDK Build Tools version (26.0.2) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.4.1.
Android SDK Build Tools 28.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '26.0.2'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
Remove Build Tools version and sync project
Affected Modules: app


这是我的项目级别gradle-


// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()

    }
}

ext {
    compileSdkVersion = 28
    buildToolsVersion = '26.0.2'
    minSdkVersion = 23
    targetSdkVersion = 28
    supportLibraryVersion = '26.1.0'
    daggerVersion = '2.11'
    retrofitVersion = '2.3.0'
    moshiVersion = '1.5.0'
    autoValueVersion = '1.5.1'
    autoValueMoshiVersion = '0.4.3'
    rxJavaVersion = '2.1.4'
    rxAndroidVersion = '2.0.1'
    rxRelayVersion = '2.0.0'
    conductorVersion = '2.1.4'
}

task clean(type: Delete) {
    delete rootProject.buildDir
}


这是我的应用级别奖赏-


apply plugin: 'com.android.application'

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion
    defaultConfig {
        applicationId "com.example.androidadvanced1"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation "com.android.support:appcompat-v7:$supportLibraryVersion"
    implementation "com.android.support:design'$supportLibraryVersion"

    implementation "com.google.dagger:dagger-android:$daggerVersion"
    implementation "com.google.dagger:dagger-android-support:$daggerVersion"
    annotationProcessor "com.google.dagger:dagger-android-processor:$daggerVersion"
    annotationProcessor "com.google.dagger:dagger-compiler:$daggerVersion"

    implementation "com.squareup.retrofit2:retrofit:$retrofitVersion"
    implementation "com.squareup.retrofit2:converter-moshi:$retrofitVersion"
    implementation "com.squareup.moshi:moshi:$moshiVersion"
    annotationProcessor "com.ryanharter.auto.value:auto-value-moshi:$autoValueMoshiVersion"
    compileOnly "com.ryanharter.auto.value:auto-value-moshi-annotations:$autoValueMoshiVersion"

    compileOnly "com.google.auto.value:auto-value:$autoValueVersion"
    annotationProcessor "com.google.auto.value:auto-value:$autoValueVersion"

    implementation "io.reactivex.rxjava2:rxjava:$rxJavaVersion"
    implementation "io.reactivex.rxjava2:rxandroid:$rxAndroidVersion"
    implementation "com.jakewharton.rxrelay2:rxrelay:$rxRelayVersion"

    implementation "com.bluelinelabs:conductor:$conductorVersion"

    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}


我在做什么错了?

2 个答案:

答案 0 :(得分:0)

更新您的Gradle朋友,您的Android Studio版本,gradle和依赖项应该匹配。

答案 1 :(得分:0)

可能是您的某些依赖项相互依赖,并且您的版本号可能冲突。例如。您可能具有依赖项 x ,这可能需要特定版本的依赖项 y ,但是您安装了另一个版本的依赖项 y 。因此,请检查与依赖项之间是否存在任何冲突的版本号。