Skip to content

Missing classes when minifying with R8 #2392

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hristogochev opened this issue Aug 3, 2023 · 5 comments
Closed

Missing classes when minifying with R8 #2392

hristogochev opened this issue Aug 3, 2023 · 5 comments

Comments

@hristogochev
Copy link

Attempting to obfuscate and shrink any app that uses the kotlinx.datetime library (which depends on this library) results in the following errors caused by the proguard rules of this library:

> Task :app:minifyReleaseWithR8 FAILED
AGPBI: {"kind":"error","text":"Missing class kotlinx.serialization.KSerializer (referenced from: kotlinx.datetime.serializers.InstantIso8601Serializer)\nMissing class kotlinx.serialization.Serializable (referenced from: kotlinx.datetime.Instant)","sources":[{}],"tool":"R8"}

To Reproduce

  1. Create a new Android app.
  2. Add the following dependency: implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.4.0").
  3. Create a new class which includes a field that is of type "Instant" and use it somewhere.
  4. Attempt to obfuscate and shrink the app in release.

Environment

  • Kotlin version: 1.9.0
  • Library version: 1.5.0
  • Kotlin platforms: Android JVM
  • Gradle version: 8.1.0
@MarcelReiter
Copy link

Isn't this an issue of kotlinx.datetime rather than kotlinx.serialization?

@hristogochev
Copy link
Author

hristogochev commented Aug 3, 2023

I was wondering if I should open it there instead of here, but ultimately decided to post it here because it seems classes annotated with Serializable get obfuscated when they should not. If a team member thinks It's more appropriate for me to open it at kotlinx.datetime they can close this issue and I will open it in the appropriate repository.

@sandwwraith
Copy link
Member

Given the line referenced from: kotlinx.datetime.serializers.InstantIso8601Serialize I guess it is kotlinx.datetime classes that got incorrectly obfuscated rather than kotlinx.serialiaztion classes. kotlinx.serialization distributes own proguard rules anyway. So I'd recommend open this issue in kotlinx.datetime

@MarcelReiter
Copy link

MarcelReiter commented Aug 3, 2023

I created an issue for this in the kotlinx.datetime github:
Kotlin/kotlinx-datetime#297

It includes a minimal reproducible github project

@hristogochev
Copy link
Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants