Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Record requires ASM8 when using 1.13.0-SNAPSHOT #1424

Closed
mateuszkwiecinski opened this issue Nov 16, 2021 · 13 comments
Closed

Record requires ASM8 when using 1.13.0-SNAPSHOT #1424

mateuszkwiecinski opened this issue Nov 16, 2021 · 13 comments
Labels

Comments

@mateuszkwiecinski
Copy link

I tried to use SNAPSHOT version to overcome #1368, but it produces a compile time error:

Execution failed for task ':app:mergeExtDexDebug'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Failed to transform converter-moshi-2.9.0.jar (com.squareup.retrofit2:converter-moshi:2.9.0) to match attributes {artifactType=android-dex, asm-transformed-variant=debug, dexing-enable-desugaring=true, dexing-is-debuggable=true, dexing-min-sdk=23, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.
      > Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
         > Failed to transform moshi-1.13.0-SNAPSHOT.jar (com.squareup.moshi:moshi:1.13.0-SNAPSHOT:20211115.162901-24) to match attributes {artifactType=android-asm-instrumented-jars, asm-transformed-variant=debug, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.jvm.version=8, org.gradle.libraryelements=jar, org.gradle.status=integration, org.gradle.usage=java-runtime, org.jetbrains.kotlin.localToProject=public, org.jetbrains.kotlin.platform.type=jvm}.
            > Execution failed for AsmClassesTransform: ~/.gradle/caches/modules-2/files-2.1/com.squareup.moshi/moshi/1.13.0-SNAPSHOT/6d591b37313d7f58c2cc7776bb2c346ec7b712a8/moshi-1.13.0-SNAPSHOT.jar.
               > Record requires ASM8
   > Failed to transform moshi-1.13.0-SNAPSHOT.jar (com.squareup.moshi:moshi:1.13.0-SNAPSHOT:20211115.162901-24) to match attributes {artifactType=android-dex, asm-transformed-variant=debug, dexing-enable-desugaring=true, dexing-is-debuggable=true, dexing-min-sdk=23, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.jvm.version=8, org.gradle.libraryelements=jar, org.gradle.status=integration, org.gradle.usage=java-runtime, org.jetbrains.kotlin.localToProject=public, org.jetbrains.kotlin.platform.type=jvm}.
      > Execution failed for AsmClassesTransform: ~/.gradle/caches/modules-2/files-2.1/com.squareup.moshi/moshi/1.13.0-SNAPSHOT/6d591b37313d7f58c2cc7776bb2c346ec7b712a8/moshi-1.13.0-SNAPSHOT.jar.
         > Record requires ASM8

My setup uses com.squareup.moshi:moshi with kapt com.squareup.moshi:moshi-kotlin-codegen. The error happens as soon as I bump moshi dependency. I observe the same behavior regardles if 1.5.31 or 1.6.0 Kotlin version is used.

I wanted to try snapshot built before #1393 or #1394 but I couln't find such. Is it possible that one of linked PRs changed something and generated artifactes contains Records which aren't available on Android and Java 11?

@ZacSweers
Copy link
Collaborator

We ship an MR-jar, whatever tool you're using should not be looking at the record classes (embedded in the shipped jar's resources) unless it's targeting Java 16+. I would encourage you to seek build system support through gradle's appropriate channels

@ZacSweers
Copy link
Collaborator

Alternatively - force a newer ASM version in your build classpath. ASM 8 is fairly old

@mateuszkwiecinski
Copy link
Author

Thanks for the reply 🙏 I haven't fully understood what you said to me, but it's something I can work with 😅

I'll share that I started looking into what ASM is and why something started picking Java 16 despite my whole toolchain is on Java 11 and found out the thing that breaks moshi 1.13.0 for me is com.google.firebase.firebase-perf plugin from Google :/ https://firebase.google.com/docs/perf-mon/get-started-android

I was able to reproduce the issue in my playground project:
mateuszkwiecinski/github_browser#151

First commit adds moshi dependency which passes the build, second commit enables the plugin and makes the build fail with the same stacktrace as I initially reported.

I'll continue investigating and will share my findings as soon as I make moshi working for me again 👀

@ZacSweers
Copy link
Collaborator

ah interesting, not sure why firebase is digging around in there

@ZacSweers
Copy link
Collaborator

I filed this issue over to AGP https://issuetracker.google.com/issues/206655905

@Hussienfahmy
Copy link

I have the same issue and am not using com.google.firebase.firebase-perf

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:checkDebugDuplicateClasses'.
Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
Caused by: org.gradle.api.internal.artifacts.transform.TransformException: Failed to transform moshi-1.13.0-SNAPSHOT.jar (com.squareup.moshi:moshi:1.13.0-SNAPSHOT:20211206.021000-40) to match attributes {artifactType=enumerated-runtime-classes, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.jvm.environment=standard-jvm, org.gradle.jvm.version=8, org.gradle.libraryelements=jar, org.gradle.status=integration, org.gradle.usage=java-runtime, org.jetbrains.kotlin.platform.type=jvm}.
Caused by: org.gradle.api.internal.artifacts.transform.TransformException: Execution failed for JetifyTransform: /home/hussien/.gradle/caches/modules-2/files-2.1/com.squareup.moshi/moshi/1.13.0-SNAPSHOT/d5ad7028265f6e4b24c0bfc32c331378c73176eb/moshi-1.13.0-SNAPSHOT.jar.
Caused by: java.lang.RuntimeException: Failed to transform '/home/hussien/.gradle/caches/modules-2/files-2.1/com.squareup.moshi/moshi/1.13.0-SNAPSHOT/d5ad7028265f6e4b24c0bfc32c331378c73176eb/moshi-1.13.0-SNAPSHOT.jar' using Jetifier. Reason: UnsupportedOperationException, message: Records requires ASM8. (Run with --stacktrace for more details.)
Suggestions:
 - Check out existing issues at https://issuetracker.google.com/issues?q=componentid:460323&s=modified_time:desc, it's possible that this issue has already been filed there.
 - If this issue has not been filed, please report it at https://issuetracker.google.com/issues/new?component=460323 (run with --stacktrace and provide a stack trace if possible).
	at com.android.build.gradle.internal.dependency.JetifyTransform.transform(JetifyTransform.kt:190)
Caused by: java.lang.UnsupportedOperationException: Records requires ASM8
	at org.objectweb.asm.ClassVisitor.visit(ClassVisitor.java:112)
	at org.objectweb.asm.commons.ClassRemapper.visit(ClassRemapper.java:88)
	at org.objectweb.asm.ClassReader.accept(ClassReader.java:536)
	at org.objectweb.asm.ClassReader.accept(ClassReader.java:394)
	at com.android.tools.build.jetifier.processor.AndroidXRefScanner.visit(AndroidXRefScanner.kt:83)
	at com.android.tools.build.jetifier.processor.archive.ArchiveFile.accept(ArchiveFile.kt:53)
	at com.android.tools.build.jetifier.processor.AndroidXRefScanner.visit(AndroidXRefScanner.kt:67)
	at com.android.tools.build.jetifier.processor.archive.Archive.accept(Archive.kt:77)
	at com.android.tools.build.jetifier.processor.AndroidXRefScanner.scan(AndroidXRefScanner.kt:57)
	at com.android.tools.build.jetifier.processor.Processor.filterOutLibrariesWithAndroidX(Processor.kt:379)
	at com.android.tools.build.jetifier.processor.Processor.transform2(Processor.kt:283)
	at com.android.build.gradle.internal.dependency.JetifyTransform.transform(JetifyTransform.kt:141)

@mateuszkwiecinski
Copy link
Author

mateuszkwiecinski commented Dec 6, 2021

@Hussienfahmy It seems like you've encountered an issue with Jetifier: https://issuetracker.google.com/issues/172784894

I'd personally recommend trying to disabe Jetifier in your project, I'd guess it isn't needed at all (here's a library which can help you confirming that: https://github.com/dipien/bye-bye-jetifier)

The alternative is to apply one of the workarounds mentioned in the above issue or wait for AGP 7.2.0-beta01 which should contain a fix of the root cause reported by Zac above which I believe should fix your issue as well

@Hussienfahmy
Copy link

@mateuszkwiecinski I tried the plugin you mentioned and there's a support libraries used by com.squareup.picasso
But I tried to build the project again and it worked with no errors!

@JakeWharton
Copy link
Member

Try Picasso 2.8

@zhuhuitao
Copy link

When i remove android.enableJetifier=true,It's immediately ok.

alvindizon added a commit to alvindizon/MVVMNewsApp that referenced this issue Dec 31, 2021
- There is an issue with Moshi that prevents users from using its latest version unless they upgrade to AGP 7.2, which is not a stable release.
One of the workarounds is to disable Jetifier, see square/moshi#1424 (comment).

Signed-off-by: Alvin Dizon <alvin.dizon91@gmail.com>
@FilippoVigani
Copy link

FilippoVigani commented Jan 12, 2022

@mateuszkwiecinski How did you go about finding out which dependency caused the issue? I'm not using firebase-perf but I'm not sure what the steps to figure out what's causing the issue are.

For clairty I'm not using jetifier either so I have no clue what could be causing the issue or how to fix it.

@ZacSweers any ideas?

@mateuszkwiecinski
Copy link
Author

@FilippoVigani I started commenting out the code until it started compiling again. (at some point I realised Moshi iself was perfectly fine and I new the issue was caused by some other dependency)

or how to fix it.

Here's the root cause https://issuetracker.google.com/issues/206655905 and according to the comment all should be working when you upgrade to AGP >=7.2.0-alpha06, although I can see you have identify a suspect - the Sentry Gradle plugin. Good luck!

@wahyupermadie
Copy link

wahyupermadie commented Jun 30, 2023

Hi @mateuszkwiecinski do u find the solution to fix this ? I got the issue and trying to update my dependencies, but the issue still exist.

AGP to 7.2.2,
Wrapper 7.3.3
Firebase bom 25.10.0
Firebase_perf to 1.4.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants