android / nowinandroid

A fully functional Android app built entirely with Kotlin and Jetpack Compose
Apache License 2.0
15.92k stars 2.81k forks source link

Remove desugaring from this project #1485

Closed Jaehwa-Noh closed 4 weeks ago

Jaehwa-Noh commented 1 month ago

What I have done and why

We can remove desugaring from this project. The only usage of desugar API is just here. https://github.com/android/nowinandroid/blob/85129e4660f7a27c7081f4ac21169d19db89fbb6/core/ui/src/main/kotlin/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCard.kt#L242-L247

When we remove the desugaring, we can remove androidDesugarJdkLibs dependency. Output APK's size is reduced 1MB. image

And there's no need to use JAVA 11 whether even use the desugaring, the JAVA version bumped at #1392 PR

alexvanyo commented 4 weeks ago

We use desugaring in a lot more places than just that one with our usage of kotlinx-datetime for time APIs on older SDK versions. This PR will crashes at startup on an API 21 device.

Using desugaring adds size to the APK (like any library), but for our minified release it is around 0.2 MB, which seems well worth it to be able to use much better time APIs.