Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to solve ASM Instrumentation process wasn't able to resolve some classes?

When I build the app
./gradlew assembleRelease
then I get this warning:

ASM Instrumentation process wasn't able to resolve some classes, this means that
the instrumented classes might contain corrupt stack frames. Make sure the
dependencies that contain these classes are on the runtime or the provided
classpath. Otherwise, the jvm might fail to load the corrupt classes at runtime
when running in a jvm environment like unit tests.

Classes that weren't resolved:
> sun.misc.Unsafe
> androidx.appcompat.view.ContextThemeWrapper
> com.google.common.util.concurrent.ListenableFuture
> retrofit2.Response
> javax.mail.internet.MimeBodyPart
> javax.naming.NamingException
> javax.naming.directory.Attributes

I'm currently using AGP 8.0.1

In the previous AGP version (7.4.2), the warning was worded differently:

Unable to find common super type for java/lang/reflect/Field and sun/misc/Unsafe.
Unable to find common super type for sun/misc/Unsafe and java/lang/Object.
Unable to find common super type for com/google/android/gms/internal/measurement/zznt and sun/misc/Unsafe.
Unable to find common super type for androidx/appcompat/view/ContextThemeWrapper and android/content/Context.
Unable to find common super type for com/google/common/util/concurrent/ListenableFuture and androidx/work/InputMerger.
Unable to find common super type for java/lang/Throwable and retrofit2/Response.
Unable to find common super type for java/lang/Exception and javax/mail/internet/MimeBodyPart.
Unable to find common super type for javax/naming/NamingException and javax/naming/directory/Attributes.
Unable to find common super type for java/lang/Object and javax/naming/directory/Attributes.
Unable to find common super type for java/lang/reflect/Field and sun/misc/Unsafe.
Unable to find common super type for sun/misc/Unsafe and java/lang/Object.
Unable to find common super type for com/google/android/recaptcha/internal/zzjo and sun/misc/Unsafe.
Unable to find common super type for java/lang/reflect/Field and sun/misc/Unsafe.
Unable to find common super type for sun/misc/Unsafe and java/lang/Object.
Unable to find common super type for com/google/android/gms/internal/firebase-auth-api/zzaje and sun/misc/Unsafe.

I suspect the message change is related to https://issuetracker.google.com/issues/231997058 but I still have no idea how to fix this warning

like image 866
dees91 Avatar asked Jan 30 '26 22:01

dees91


1 Answers

I was the original reporter of this issue and I think there's not much to do from your side as a user. Some of the libraries declare their dependencies as compileOnly and this warning is printed when ASM instrumentation is trying to resolve types from those compileOnly dependencies while they are not present at runtime.

But there's nothing wrong with that per se, if the library declaring compileOnly dependency has proper runtime checks to not even call to the classes from that dependency, if it's not present on the classpath.

But I think it might be worth pinging that issue on google tracker because I also think this doesn't make sense to print this warning, especially in the case like

Unable to find common super type for sun/misc/Unsafe and java/lang/Object.
like image 73
romtsn Avatar answered Feb 01 '26 12:02

romtsn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!