Failed to transform jar to match attributes
Asked Answered
E

5

7
Execution failed for task ':app:checkClassicGooglePlayDebugDuplicateClasses'.
> Could not resolve all files for configuration ':app:classicGooglePlayDebugRuntimeClasspath'.
   > Failed to transform SaaS_TalkingDataSDK_Android_V5.0.0.jar to match attributes {artifactType=enumerated-runtime-classes, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
      > Execution failed for EnumerateClassesTransform: /home/circleci/project/app/libs/SaaS_TalkingDataSDK_Android_V5.0.0.jar.
         > zip END header not found

I am getting this error in Android project which has following configurations

build:gradle:7.0.4

And android.useAndroidX=true android.enableJetifier=true in gradle.properties

Easterling answered 21/1, 2022 at 16:52 Comment(3)
Can you share the build.gradle files?Hickory
It sounds like this issue -> issuetracker.google.com/issues/195441712Malinin
@Easterling were you able to fix this issueJobless
I
10

use jdk 17 it's solve my problem

Isaisaac answered 18/12, 2023 at 6:51 Comment(2)
Thank you very much!!! I spent 3 days trying to resolve this. I searched many sites and nothing was helpful. Thank you, again!Sugihara
It happens for me on JDK 21Christalchristalle
C
3

If it happens locally, just delete the corrupted cache and restart Android Studio (or IntelliJ IDEA). Cache location for Gradle is in ~/.gradle.

If you want to clear cache in Circle CI, refer to this article: Clear project dependency cache

Source: a similar question.

Chamomile answered 25/1, 2022 at 12:42 Comment(2)
how does one know which cache files are corrupt or should we delete full .grandle caches?Pycnidium
@KarueBensonKarue the jar file I saw in the stack trace was corrupted, so it was enough to delete just that file.Chamomile
V
2

The solution is to update your gradle to version 8.2.1 or above. Here is a helpful article I used to diagnose the issue.

The JdkImageTransformDelegate task did not work with jdk 21+ since it expects a few different flags from the gradle, which is why switching back to jdk 17 fixes the issue as well. They fixed it in this commit. While you can just go back to jdk 17, if you already have a project using jdk 21, it is best practice to keep it the same, to guarantee the same functionality in your apps.

Vanettavang answered 15/7 at 18:57 Comment(1)
Using latest Gradle version solved my problem. Thanks a lot.Tale
E
1

Turned out that TalkingDataSDK jar was big in size so we had to install git lfs on CI to fix the issue.

Easterling answered 3/2, 2022 at 21:14 Comment(0)
D
0

I faced similar issues in my flutter project.

Execution failed for task ':flutter_cast_video:parseDebugLocalResources'.
> Could not resolve all files for configuration ':flutter_cast_video:androidApis'.
   > Failed to transform android.jar to match attributes {artifactType=android-platform-attr, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.

What helped me was reinstalling the SDK Platforms from the Android SDK

Android Studio => Settings => Language & Framework => Android SDK => SDK Platform

Uncheck all the boxes and click Apply it will uninstall all the platforms. Then just run the code the android studio will take care of the necessary things.

Derma answered 30/9 at 13:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.