任务 ':app:compileDebugAndroidTestJavaWithJavac' 执行失败
Posted
技术标签:
【中文标题】任务 \':app:compileDebugAndroidTestJavaWithJavac\' 执行失败【英文标题】:Execution failed for task ':app:compileDebugAndroidTestJavaWithJavac'任务 ':app:compileDebugAndroidTestJavaWithJavac' 执行失败 【发布时间】:2022-01-13 04:20:15 【问题描述】:当我打算为 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'
【问题讨论】:
【参考方案1】:经过搜索发现只有下面这行代码需要添加到build.gradle中
build.gradle
dependencies
//...
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.4.0'
【讨论】:
以上是关于任务 ':app:compileDebugAndroidTestJavaWithJavac' 执行失败的主要内容,如果未能解决你的问题,请参考以下文章