Can someone please help me with this? <https://st...
# announcements
j
What are you using for your
proguardFiles
statement?
i.e. are you using one of the default android proguard files, e.g.
proguard-android-optimize.txt
d
I have this inside
build.gradle
file
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), '<http://proguard-rules.pro|proguard-rules.pro>'
And I have written my rules in
<http://proguard-rules.pro|proguard-rules.pro>
j
what version of kotlin and jackson are you using?
I was going to answer on stackoverflow but I can’t seem to reproduce your exact error, so first lets solve it here so we’re certain we’ve solved your exact error, then I’ll post the solution to stackoverflow for anyone else that has this issue
d
My Kotlin version is
1.4.31
and Jackson version is
2.12.0
Sorry for replying late, I dunno why I didn't get notification. Maybe because I was watching some YouTube tutorial on full screen.
j
no worries, okay, so this error doesn’t indicate that there’s an issue with your model, it indicates that somehow, it can’t find the access for:
Copy code
kotlin.collections.EmptyList.serialVersionUID: kotlin.Long
Did you try removing
INFER_PROPERTY_MUTATORS
?
actually, nvm I guess that’s enabled by default
okay so the problem is literally that accessors and/or the field
serialVersionUID
in kotlin’s
EmptyList
object
d
were you able to replicate the issue?
j
unfortunately I wasn’t
to me, this looks like there’s an issue with serializing the object
EmptyList
because somehow kotlin reflection expects that the field
serialVersionUID
is there but r8 has removed it
r8 or proguard, either one
but you shouldn’t have to know that
listOf()
uses
EmptyList
object under the hood
try this very specific rule:
Copy code
-keepclassmembers class kotlin.collections.EmptyList {
    static final long serialVersionUID;
}
d
Building...
j
I think what’s happening is that kotlin reflect is reading the
kotlin.Metadata
which provides information to the kotlin compiler (and kotlin reflect) about
EmptyList
which r8/proguard is minifying, but it is removing
EmptyList.serialVersionUID
so it never finds that field
that shouldn’t happen though, so what version of the android gradle plugin are you on?
d
Writing that specific rule worked like a charm 😅 My project's AGP version is
4.1.3
j
try removing the rule then using
4.2.2
r8 should properly update the
kotlin.Metadata
in the bytecode when it makes changes to the underlying class, but it looks like it’s not doing that
and since r8 is packaged with the android gradle plugin, first thing I’d try is a newer version of the android gradle plugin
d
Gradle syncing...
j
if this works that’d be ideal because then you don’t need to worry about the same issue with other classes and/or other bugs that may not have been resolved
it might make you update your gradle version to 6.7.1+
i.e. in
gradle/wrapper/gradle-wrapper.properties
, updating this value:
distributionUrl=https\:<//services.gradle.org/distributions/gradle-6.7.1-bin.zip>
d
yeah, done that. the build is taking a bit time with all the downloading n all
j
sounds good
d
woah, upgrading AGP version worked
j
okay so it was a bug in R8
I’ll post the answer to stackoverflow
d
I dunno in detail
Can you explain what exactly was the issue?
And is there any way to watch that particular issue as in Github or Google issue?
j
I will answer in stackoverflow, you just need to approve
d
yeah sure
j
I don’t know of an actual r8 issue, I’m just going based on what I know about kotlin reflection and r8
d
ok
Thanks a lot @Justin sir, you saved my day
j
no problem! happy to help
just answered in stackoverflow
d
Upvoted and approved
j
great!
d
Once again, thanks
and good night
j
no problem at all, night!