Status Update
Comments
ze...@google.com <ze...@google.com> #2
This is likely due to an incorrect service loader specified somewhere.
If you are unable to fix the server loader spec, you can add a -dontwarn
rule for the class to silence the error using:
-dontwarn com.google.protobuf.java_com_google_android_gmscore_sdk_target_granule__proguard_group_gtm_N1281923064GeneratedExtensionRegistryLite$Loader
A discussion of a similar situation can be found in
ze...@google.com <ze...@google.com> #3
Could you see which service file the class is declared in? You will need to look for the class referenced META-INF/services/<somefile>
.
Alternatively you can create a
ay...@sportskeeda.com <ay...@sportskeeda.com> #4
Unexpected reference to missing service implementation class in META-INF/services/com.google.protobuf.GeneratedExtensionRegistryLoader: com.google.protobuf.java_com_google_android_gmscore_sdk_target_granule__proguard_group_gtm_N1281923064GeneratedExtensionRegistryLite$Loader.
Unexpected reference to missing service class: META-INF/services/com.google.protobuf.GeneratedExtensionRegistryLoader.
Unexpected reference to missing service class: META-INF/services/org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor.
Unexpected reference to missing service class: META-INF/services/org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar.
Unexpected reference to missing service class: META-INF/services/org.jetbrains.kotlin.diagnostics.rendering.DefaultErrorMessages$Extension.
Caused by: [CIRCULAR REFERENCE: com.android.tools.r8.utils.b: Missing class com.google.protobuf.java_com_google_android_gmscore_sdk_target_granule__proguard_group_gtm_N1281923064GeneratedExtensionRegistryLite$Loader (referenced from: java.util.List kotlinx.coroutines.internal.FastServiceLoader.load(java.lang.Class, java.lang.ClassLoader))]
ay...@sportskeeda.com <ay...@sportskeeda.com> #5
The app doesn't work with
-dontwarn com.google.protobuf.java_com_google_android_gmscore_sdk_target_granule__proguard_group_gtm_N1281923064GeneratedExtensionRegistryLite$Loader
ze...@google.com <ze...@google.com> #6
You will need a -dontwarn
for each type that is missing.
ay...@sportskeeda.com <ay...@sportskeeda.com> #7
But "missing_rules.txt" has only -dontwarn com.google.protobuf.java_com_google_android_gmscore_sdk_target_granule__proguard_group_gtm_N1281923064GeneratedExtensionRegistryLite$Loader
After adding this to pro-guard, app stops working as intended.
ay...@sportskeeda.com <ay...@sportskeeda.com> #8
I get the error:
java.lang.ClassCastException: java.lang.Class cannot be cast to java.lang.reflect.ParameterizedType
ze...@google.com <ze...@google.com> #9
Ah, you need to add it to the proguard-rules.pro
file which is the rule file that is used for compilation.
ay...@sportskeeda.com <ay...@sportskeeda.com> #10
I added it to proguard-rules.pro file only.
ze...@google.com <ze...@google.com> #11
Also, is this an R8 configured build that has worked in the past or are you just starting to use R8?
ay...@sportskeeda.com <ay...@sportskeeda.com> #12
I have added -dontwarn com.google.protobuf.java_com_google_android_gmscore_sdk_target_granule__proguard_group_gtm_N1281923064GeneratedExtensionRegistryLite$Loader to proguard-rules.pro
But I get java.lang.ClassCastException: java.lang.Class cannot be cast to java.lang.reflect.ParameterizedType and app doesn't work
ay...@sportskeeda.com <ay...@sportskeeda.com> #13
It is an old build. The project is live. I have just updated the AGP to the latest version.
ze...@google.com <ze...@google.com> #14
I'm assuming you get that exception as a runtime exception or is it a compile time issue?
I'll need a bit more information on what you are building and where the issue happens. If it is a build-time issue then the --info / --stacktrace output may be helpful.
ay...@sportskeeda.com <ay...@sportskeeda.com> #15
With "-dontwarn com.google.protobuf.java_com_google_android_gmscore_sdk_target_granule__proguard_group_gtm_N1281923064GeneratedExtensionRegistryLite$Loader" --> It is a RUNTIME exception.
Without "-dontwarn com.google.protobuf.java_com_google_android_gmscore_sdk_target_granule__proguard_group_gtm_N1281923064GeneratedExtensionRegistryLite$Loader" --> It is a BUILD time issue with
Unexpected reference to missing service implementation class in META-INF/services/com.google.protobuf.GeneratedExtensionRegistryLoader: com.google.protobuf.java_com_google_android_gmscore_sdk_target_granule__proguard_group_gtm_N1281923064GeneratedExtensionRegistryLite$Loader.
Unexpected reference to missing service class: META-INF/services/com.google.protobuf.GeneratedExtensionRegistryLoader.
Unexpected reference to missing service class: META-INF/services/org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor.
Unexpected reference to missing service class: META-INF/services/org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar.
Unexpected reference to missing service class: META-INF/services/org.jetbrains.kotlin.diagnostics.rendering.DefaultErrorMessages$Extension.
ay...@sportskeeda.com <ay...@sportskeeda.com> #16
So, it works with
-dontwarn com.google.protobuf.java_com_google_android_gmscore_sdk_target_granule__proguard_group_gtm_N1281923064GeneratedExtensionRegistryLite**
-keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation
Source:
Still figuring out the disadvantages of using "-keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation"
ze...@google.com <ze...@google.com> #17
Thanks for the update.
The need for using -keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation
points to some kind of reflection going on and the error in ClassCastException between Class
and ParameterizedType
indicates that there is indeed a reflective use of some types. Could you share the stacktrace of the ClassCastException
?
ay...@sportskeeda.com <ay...@sportskeeda.com> #18
We aren't using ParameterizedType anywhere directly in the app. Can't share the stacktrace of the ClassCastException because the error only occurs when R8 in enabled and logs in this way:
at wn.p.b(SourceFile:2512) at wn.p0.c(SourceFile:25) at w9.j.invoke(SourceFile:251) at java.lang.reflect.Proxy.invoke(Proxy.java:1006) at $Proxy9.h(Unknown Source) at hi.u0.invokeSuspend(SourceFile:69) at hi.u0.invoke(SourceFile:13) at ii.c.invokeSuspend(SourceFile:273) at am.a.resumeWith(SourceFile:9) at rm.j0.run(SourceFile:114) at cd.f5.run(SourceFile:16) at xm.i.run(SourceFile:3) at xm.a.run(SourceFile:94)
ze...@google.com <ze...@google.com> #19
Yes, I suspect that the issue is in some library that is missing a keep rule for a reflective use.
Could you retrace the stack trace using your mapping file. The mapping file is default written to app/build/outputs/mapping/<yourapp>/mapping.txt
and you can retrace it using the R8 retracer by fetching it with:
wget https://storage.googleapis.com/r8-releases/raw/8.1.50/r8retrace.jar
and running it with:
java -cp r8retrace.jar com.android.tools.r8.retrace.Retrace mapping.txt <stacktrace-file>
ay...@sportskeeda.com <ay...@sportskeeda.com> #20
Thanks! After tracing I suspect Retrofit is the culprit -> retrofit2.Retrofit.nextCallAdapter(retrofit2.CallAdapter$Factory,java.lang.reflect.Type,java.lang.annotation.Annotation
ze...@google.com <ze...@google.com> #21
Great to find the origin. If you file an issue with retrofit, please do add a link to it in this issue.
Closing for now as this looks like it is WAI from the compiler perspective.
ay...@sportskeeda.com <ay...@sportskeeda.com> #22
Sure! Thanks a lot for the timely response. Really appreciate! :)
je...@23andme.com <je...@23andme.com> #24
Hi there. I have the exact same issue, which started once I updated com.android.tools.build:gradle
from 7.4.2
to 8.1.2
. I resolved using the -dontwarn
solution from
I was just curious how you're able to trace this issue to Retrofit. I can't find anything related to GeneratedExtensionRegistryLite
or FastServiceLoader
in the
Thank you!
sg...@google.com <sg...@google.com> #25
Requiring -keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation
was an issue which came up after the initially reported issue was resolved with adding a -dontwarn
, which made the project build, but then fail at runtime..
The AGP upgrade also required that ekstra rule (which is shipped with recent Retrofit versions), and that was found from retracing the stack trace from
Description