Status Update
Comments
mk...@google.com <mk...@google.com>
mk...@google.com <mk...@google.com> #2
Thank you for the nice reproduction. The problem is in the library that defines a service loader implementation file incorrectly. The file META-INF/services/org.xmlpull.v1.XmlPullParserFactory contains:
org.kxml2.io.KXmlParser,org.kxml2.io.KXmlSerializer
The spec clearly states that it should be one per line:
A service provider is identified by placing a provider-configuration file in the resource directory META-INF/services. The file's name is the fully-qualified binary name of the service's type. The file contains a list of fully-qualified binary names of concrete provider classes, one per line...
R8 also gives a warning regarding that:
Warning in /usr/local/google/home/mkroghj/dumps/b279996549/dump/program.jar:META-INF/services/org.xmlpull.v1.XmlPullParserFactory:
Unexpected reference to missing service implementation class in META-INF/services/org.xmlpull.v1.XmlPullParserFactory: org.kxml2.io.KXmlParser,org.kxml2.io.KXmlSerializer.
The reason the context is FastServiceLoader.load
is because that is where we enqueue the potential services that can be loaded. I guess this could try and figure out the concrete types that could be loaded instead of all types, but that is difficult since the method takes a class as argument.
R8 will read the type in the implementation as a type with name org.kxml2.io.KXmlParser,org.kxml2.io.KXmlSerializer
. You therefore, in principle, need to write -dontwarn org.kxml2.io.KXmlParser,org.kxml2.io.KXmlSerializer
. Now the problem here is that -dontwarn
takes a list of classes as argument, so we parse that into something similar to:
-dontwarn org.kxml2.io.KXmlParser
-dontwarn org.kxml2.io.KXmlSerializer
The only thing you can write is a prefix, so you could do -dontwarn org.kxml2.io.KXml*
and that will silence the compiler and succeed.
Regarding the library, I checked if the error was still present, but the service file was corrected over 3 years ago:
You could see if an update of the library you are using is available or use the -dontwarn
pattern above. Will be marking this as WAI.
ua...@gmail.com <ua...@gmail.com> #3
I have tried above pattern but that also fail
-dontwarn org.kxml2.io.KXml*
Can you please confirm from sample file with corrected pattern and working solution ?
mk...@google.com <mk...@google.com> #4
It should be two **. You can decide on any prefix you desire as long as it matches the path.
-dontwarn org.kxml2.io.KXml**
ua...@gmail.com <ua...@gmail.com> #5
Thanks mk@, using that pattern issue resolved for now.
su...@gmail.com <su...@gmail.com> #6
sh...@gmail.com <sh...@gmail.com> #7
jo...@innocv.com <jo...@innocv.com> #8
java.lang.IncompatibleClassChangeError: Class 'android.content.res.XmlBlock$Parser' does not implement interface 'org.xmlpull.v1.a' in call to 'int org.xmlpull.v1.a.next()' (declaration of 'androidx.core.content.FileProvider' appears in base.apk). Gradle 8.0 AGP 8.1.4
I solved it setting this proguard rule.
-keep class org.xmlpull.v1.** {*;}
sg...@google.com <sg...@google.com> #9
org.xmlpull.v1
in your input. Classes in that namespace are also in the Android runtime,
dt...@gmail.com <dt...@gmail.com> #10
i have a slightly different warning message
Missing class org.kxml2.io.KXmlParser,org.kxml2.io.KXmlSerializer (referenced from: java.util.List androidx.test.internal.platform.ServiceLoaderWrapper.loadService(java.lang.Class))
Tried all patterns provided wiithout success:
-dontwarn org.kxml2.io.KXmlParser,org.kxml2.io.KXmlSerializer
-dontwarn org.kxml2.io.KXmlParser
-dontwarn org.kxml2.io.KXmlSerializer
-dontwarn org.kxml2.io.KXml*
-dontwarn org.kxml2.io.KXml**
dt...@gmail.com <dt...@gmail.com> #11
it turns out in my case (AGP 8.0) the error was referring releaseAndroidTest which needs its own testProguardFiles, as described in
Description
Here is sample code to reproduce below error when you try to run app in emulator
Missing class org.kxml2.io.KXmlParser,org.kxml2.io.KXmlSerializer (referenced from: java.util.List kotlinx.coroutines.internal.FastServiceLoader.load(java.lang.Class, java.lang.ClassLoader))