Enabling R8 in android kotlin app cause Library class android.content.res.XmlResourceParser implements program class org.xmlpull.v1.XmlPullParser
Asked Answered
A

3

16

I enabled R8 plugging for obfuscation

I got an exception when I am trying to generate the signed apk

"Library class android.content.res.XmlResourceParser implements program class org.xmlpull.v1.XmlPullParser"

I have added below proGuard rule to the proguard-rules.pro file

-dontwarn org.xmlpull.v1.**
-dontnote org.xmlpull.v1.**
-keep class org.xmlpull.** { *; }
-keepclassmembers class org.xmlpull.** { *; }

and My release build specification

buildTypes {
        release {
            useProguard false
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
        }
    }

Help to fix this issue

Acetanilide answered 22/10, 2021 at 7:19 Comment(3)
Did you figure out a solution for this issue?Sieber
@Sean, I have added -keep class org.xmlpull.v1.* {*;} this alone to my proguard ruleAcetanilide
Is there any solution on this issue?Conscience
M
14

Add these lines in proguard-rules file:

-dontwarn org.xmlpull.v1.**
-dontwarn org.kxml2.io.**
-dontwarn android.content.res.**
-dontwarn org.slf4j.impl.StaticLoggerBinder

-keep class org.xmlpull.** { *; }
-keepclassmembers class org.xmlpull.** { *; }

Am 100% sure these lines will resolve your issue.

Milo answered 23/5, 2023 at 7:10 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Gunslinger
T
8

gradle.properties

android.enableR8.fullMode=false
Toponym answered 24/4, 2023 at 8:21 Comment(2)
That and only that actually helped me. The problem occurred after I updated to Android Gradle Plugin 8.0.0. Reason: With Android Gradle Plugin 8.0.0 the default changed from false to trueMeasure
This answer might be a quick fix if you need to do a release today, but in general app size / performance is impacted a lot if R8 full mode is disabled. As there are suggestions here, try them out before recurring to just disabling R8.God
C
2

Surprisingly, I have the same issue and adding these lines, mentioned by the question poster to my proguard-rules.pro solved it :

-dontwarn org.xmlpull.v1.**
-dontnote org.xmlpull.v1.**
-keep class org.xmlpull.** { *; }
-keepclassmembers class org.xmlpull.** { *; }
Cindelyn answered 3/5, 2023 at 11:5 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.