无法解析“:app @ debugUnitTest / compileClasspath”的依赖项:无法解析androidx.constraintlayout:constraintLayout:1.1.3

时间:2020-07-22 10:09:15

标签: android-gradle-plugin android-constraintlayout

y构建失败并显示错误消息

无法解析':app @ debugUnitTest / compileClasspath'的依赖项:无法解析androidx.constraintlayout:constraintLayout:1.1.3

ConstraintLayout版本:1.1.3 Gradle插件版本:4.0.1 Gradle版本:6.1.1

我的app_build gradle如下

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.xxxxx.xxxxxxx"
        minSdkVersion 19
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintLayout:1.1.3'
    implementation 'androidx.annotation:annotation:1.1.0'
    // To use the Java-compatible @Experimental API annotation
    implementation "androidx.annotation:annotation-experimental:1.0.0"
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'

    def room_version = "2.2.5"
    def lifecycle_version = "2.2.0"

    implementation "androidx.room:room-runtime:$room_version"
    annotationProcessor "androidx.room:room-compiler:$room_version"

    // For Lifecycle dependencies:
    implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
    annotationProcessor "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"

    // optional - RxJava support for Room
    implementation "androidx.room:room-rxjava2:$room_version"

    // Test helpers
    testImplementation "androidx.room:room-testing:$room_version"

}

我的项目build.gradle是

buildscript {
   
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.0.1'


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

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

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

1 个答案:

答案 0 :(得分:0)

jcenter()中不存在androidx.constraintlayout包

https://jcenter.bintray.com/androidx/

但是您可以做什么

allprojects { 储存库{ mavenCentral() 谷歌() jcenter() 专家{ //对于房间持久性库 网址“ https://maven.google.com” } }