Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build fails when targeting Android Q but works at API 28 with "Failed to transform file 'android.jar' to match attributes"

I've got a legacy app I'm maintaining that builds fine when targeting API 28 but fails at Q.

The full error from the gradle build looks like this:

> Task :lintVitalRelease
Calling mockable JAR artifact transform to create file: /Users/spartygw/.gradle/caches/transforms-1/files-1.1/android.jar/5fe3ee8a258b0a02d9b262c195a9ab63/android.jar with input /Users/spartygw/Library/Android/sdk/platforms/android-Q/android.jar

> Task :lintVitalRelease FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':lintVitalRelease'.
> Could not resolve all files for configuration ':androidApis'.
   > Failed to transform file 'android.jar' to match attributes {artifactType=android-mockable-jar, returnDefaultValues=false} using transform MockableJarTransform
      > Cannot create mockable android.jar

I've followed the guidelines for setting up the Android Q SDK from here.

I'm building from a command line outside of Android Studio.

I see the build progress through building the jni library but barfs immediately when it gets to java byte compilation.

EDIT: Because I can't include the entire gradle stack (limited to 30,000 bytes in a post) here is the synopsis:

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':lintVitalRelease'.
Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':androidApis'.
Caused by: org.gradle.api.artifacts.transform.ArtifactTransformException: Failed to transform file 'android.jar' to match attributes {artifactType=android-mockable-jar, returnDefaultValues=false} using transform MockableJarTransform
Caused by: java.lang.RuntimeException: Cannot create mockable android.jar
Caused by: java.util.zip.ZipException: invalid entry compressed size (expected 1821 but got 1807 bytes)
        at com.android.builder.testing.MockableJarGenerator.createMockableJar(MockableJarGenerator.java:96)
        at com.android.build.gradle.internal.dependency.MockableJarTransform.transform(MockableJarTransform.java:54)
        ... 109 more
        Suppressed: java.util.zip.ZipException: invalid entry compressed size (expected 1821 but got 1807 bytes)
like image 266
spartygw Avatar asked Mar 05 '23 06:03

spartygw


1 Answers

Those of you who are coming through google search and already have the latest gradle installed

Just delete the Android Q SDK and reinstall. The jars from left over beta install is probably messing with the final release

like image 119
Ganesh Krishnan Avatar answered Apr 30 '23 08:04

Ganesh Krishnan