11

我正在使用 Android 3.0 canary 4 并制作应用程序。直到昨天一切正常,但是今天当我打开项目时,它给了我一个错误

 F:\test projects\SellIT\app\build.gradle
Error:Failed to resolve: Failed to transform file '45907c80e09917e1b776adf038505958' to match attributes {artifactType=jar} using transform AarTransform
<a href="openFile:F:/test projects/SellIT/app/build.gradle">Open File</a>

Error:Failed to resolve: Failed to transform file '0424053f6b3433893454e7542cca3a9d' to match attributes {artifactType=jar} using transform AarTransform
<a href="openFile:F:/test projects/SellIT/app/build.gradle">Open File</a>

Error:Failed to resolve: Failed to transform file 'customtabs-25.0.0.aar' to match attributes {artifactType=android-exploded-aar} using transform ExtractAarTransform
<a href="openFile:F:/test projects/SellIT/app/build.gradle">Open File</a>

Error:Failed to resolve: Failed to transform file 'recyclerview-v7-25.4.0.aar' to match attributes {artifactType=android-exploded-aar} using transform ExtractAarTransform
<a href="openFile:F:/test projects/SellIT/app/build.gradle">Open File</a>

Error:Failed to resolve: Failed to transform file 'b7ae5d97f624a2ac68ed171c25f74f21' to match attributes {artifactType=jar} using transform AarTransform
<a href="openFile:F:/test projects/SellIT/app/build.gradle">Open File</a>

Error:Failed to resolve: Failed to transform file 'firebase-analytics-impl-10.2.4.aar' to match attributes {artifactType=android-exploded-aar} using transform ExtractAarTransform
<a href="openFile:F:/test projects/SellIT/app/build.gradle">Open File</a>

Error:Failed to resolve: Failed to transform file '8a727da2aab64813ae6d20842b03d41f' to match attributes {artifactType=jar} using transform AarTransform
<a href="openFile:F:/test projects/SellIT/app/build.gradle">Open File</a>

Error:Failed to resolve: Failed to transform file 'support-compat-25.4.0.aar' to match attributes {artifactType=android-exploded-aar} using transform ExtractAarTransform
<a href="openFile:F:/test projects/SellIT/app/build.gradle">Open File</a>

Error:Failed to resolve: Failed to transform file 'd0da7bf76907aa33e493551504efa952' to match attributes {artifactType=jar} using transform AarTransform
<a href="openFile:F:/test projects/SellIT/app/build.gradle">Open File</a>

这是我的build.gradle(应用级别)

    apply plugin: 'com.android.application'


android {
    compileSdkVersion 25
    buildToolsVersion "26.0.0"
    defaultConfig {
        applicationId "android.sellit"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    //noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:25.4.0'
    testImplementation 'junit:junit:4.12'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.google.firebase:firebase-auth:10.2.4'

    // Required only if Facebook login support is required
    implementation('com.facebook.android:facebook-android-sdk:4.22.1')
    implementation 'com.google.firebase:firebase-core:10.2.4'
    implementation 'com.google.firebase:firebase-database:10.2.4'
    implementation 'com.google.android.gms:play-services-auth:10.2.4'
    implementation 'com.android.support:design:25.4.0'

    implementation 'com.github.bumptech.glide:glide:4.0.0-RC1'

    implementation 'com.google.firebase:firebase-storage:10.2.4'

    implementation 'de.hdodenhof:circleimageview:2.1.0'
    implementation 'com.google.firebase:firebase-crash:10.2.4'

    implementation 'com.google.firebase:firebase-ads:10.2.4'
}
apply plugin: 'com.google.gms.google-services'

有没有人遇到过类似的错误,或者他知道我该怎么办?

4

5 回答 5

27

事实证明,这是 Gradle 本身的一个奇怪错误。我将它发布在谷歌论坛上,他们的一位编码员给了我一个解决方案,并将其作为 gradle 团队的问题提出。

对于解决方案,您可以清除您的项目缓存 ( C:\Users\<username>\.gradle\caches\transforms-1) 并再次重建您的项目,它会正常工作。gradle 需要一些工件来构建,这些工件存储在缓存中。因此,如果 gradle 构建失败,可以清除缓存,这将提示重新下载。只要您需要的所有工件都已下载到 Gradle 的缓存中,您就可以离线(所以离线时不要删除缓存文件夹!)

于 2017-08-07T18:06:47.283 回答
4

面临同样的问题。解决此问题的简单方法是在构建变体之间切换。这会刷新缓存的副本并解决问题。

于 2018-05-23T08:09:27.693 回答
2

该错误似乎是由损坏的 Jetified 文件引起的。

从 Gradle 缓存文件夹中的错误消息中仅删除损坏的 .jar:

rm ~/.gradle/caches/modules-2/files-2.1/path-to/some-release.aar

“路径到”可能是包名,例如,com.example.somerelease

通常我会从错误消息本身中获取要删除的文件路径,然后将其剪切并粘贴到终端中以执行rm命令。

删除整个文件夹不是最佳解决方案,因为所有依赖项都需要再次 Jetified。如果您已经遇到损坏问题,您可能会再次遇到该问题,因为 Jetify 在必须重新处理整个文件夹时还有更多工作要做

于 2019-05-23T03:52:32.837 回答
1

收到类似的错误:

无法转换文件 'uat-release.jar' 以匹配属性 {artifactType=android-classes} 转换输出文件 D:\R\project\uat-release.jar 不存在。

就我而言,实际文件是aar并且误将.jar放入 build.gradle(uat-release 模块)

  configurations.maybeCreate("default")
  artifacts.add("default", file('uat-release.jar'))

通过更正文件类型解决它:

  configurations.maybeCreate("default")
  artifacts.add("default", file('uat-release.aar'))
于 2018-03-07T09:18:26.157 回答
0

前往目的地: Android\sdk\platforms\android-30\android.jar。 并删除 android-jar 中的内容并重建项目和同步对我有用。

于 2021-03-31T23:12:19.550 回答