任务 ':app:compileDebugAndroidTestJavaWithJavac' 执行失败

Execution failed for task ':app:compileDebugAndroidTestJavaWithJavac'

当我打算通过 espresso 编写 ui 测试时,我收到以下错误 运行 要测试的应用程序

错误

Execution failed for task ':app:compileDebugAndroidTestJavaWithJavac'.
> Could not resolve all files for configuration ':app:debugAndroidTestCompileClasspath'.
   > Failed to transform transition-1.2.0.jar (androidx.transition:transition:1.2.0) to match attributes {artifactType=android-classes-jar, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-api}.
      > Could not find transition-1.2.0.jar (androidx.transition:transition:1.2.0).
        Searched in the following locations:
            https://dl.google.com/dl/android/maven2/androidx/transition/transition/1.2.0/transition-1.2.0.jar

build.gradle

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.android.material:material:1.4.0'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
    implementation 'com.google.android.gms:play-services-maps:17.0.0'
    implementation 'androidx.navigation:navigation-fragment:2.3.5'
    implementation 'androidx.navigation:navigation-ui:2.3.5'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test:runner:1.4.0'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test:rules:1.0.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

查找后发现只需要在build.gradle

中添加下面这行代码

build.gradle

dependencies {
//...

androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.4.0'

}