首页 > 解决方案 > 无法解决android studio中的依赖关系,为什么会发生这种情况?

问题描述

我关闭了我的android项目,突然当我想再次打开我的项目时它给了我错误???

错误:无法解析“:app@debugAndroidTest/compileClasspath”的依赖关系:无法解析androidx.Test:runner:1.2.0。

显示详细信息 受影响的模块:app

错误:无法解析“:app@debugAndroidTest/compileClasspath”的依赖关系:无法解析androidx.Test.espresso:espresso-core:3.2.0。显示详细信息 受影响的模块:app

错误:无法解析“:app@debugAndroidTest/compileClasspath”的依赖关系:无法解析androidx.Test.ext:junit:1.1.1。显示详细资料

受影响的模块:app

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.example.gerobokgo"
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.Test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.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 'com.google.firebase:firebase-auth:16.0.5'
    implementation 'com.google.firebase:firebase-database:16.0.4'
    implementation 'com.google.firebase:firebase-core:16.0.8'
    implementation 'com.firebaseui:firebase-ui-database:4.3.2'
    implementation 'com.google.firebase:firebase-storage:16.0.4'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.Test:runner:1.2.0'
    androidTestImplementation 'androidx.Test.espresso:espresso-core:3.2.0'
    androidTestImplementation 'androidx.Test.ext:junit:1.1.1'

    implementation 'com.squareup.picasso:picasso:2.5.2'
    //Layout
    implementation 'com.google.android.material:material:1.0.0'
    //recylervieer
    implementation 'androidx.recyclerview:recyclerview:1.0.0'

    // image slider
    implementation 'com.github.therealshabi:AutoImageFlipper:v1.4.1'

    //image Cropper
    implementation 'com.theartofdev.edmodo:android-image-cropper:2.1.+'
    implementation 'androidx.work:work-runtime:2.2.0'
}

// 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.5.0'
        classpath 'com.google.gms:google-services:4.2.0'

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

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

    }
}

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


标签: javaandroidbuild.gradle

解决方案


您在依赖项中有一个大写 T,请使用以下

androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'

推荐阅读