Failed to transform file '**.jar' to match attributes {artifactType=android-classes} using transform

最近接手别人项目用androidStudio 3.0.0编译时发现错误如下:

Could not resolve all files for configuration ':view-busipresenter:debugAndroidTestRuntimeClasspath'.
> Failed to transform file 'appbase.jar' to match attributes {artifactType=android-classes} using transform JarTransform
   > Transform output file C:\Users\wenpingm\Desktop\A8_Project\source_code\Settings\funcpresenter-model\jar\appbase.jar does not exist.
> Failed to transform file 'systemService-proxy.jar' to match attributes {artifactType=android-classes} using transform JarTransform
   > Transform output file C:\Users\wenpingm\Desktop\A8_Project\source_code\Settings\funcpresenter-model\jar\systemService-proxy.jar does not exist.

后来网上找了大半天,也有类似差不多的问题,尝试过都不行,后来自己在仔细阅读浏览build文件时发现真正引起错误的原因如下:

-   compile fileTree(include: ['*.jar'], dir: 'libs')
    //        implementation 'com.android.support:appcompat-v7:27.1.1'
    //    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    //    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'
    compile files('jar/appbase.jar')
    compile files('jar/systemService-proxy.jar')

总结:从上面可以看出 compile fileTree(.jar)和下面compile files(‘jar/appbase.jar’)是重复的,当然也有别的原因引起这样的原因,记得谷歌官方论坛也有人提过这样错误,说是gradle 本身有点小bug,原文引用如下“It turns out that this is a weird bug in the Gradle itself. I posted it on google forum and one of their coders gave me a solution and also put it up as an issue with the gradle team.”

你可能感兴趣的:(Android)