AutoValue is a powerful tool provided by Google to generate Java immutable value classes. If you are migrating your project to Kotlin, data classes are the most direct way to replace it while keeping the same features. There are however trade-offs to take into account.
In this talk we introduce how we migrated our project from AutoValue to Kotlin data classes and how we dealt with the issues we encountered along the way. We also discuss the advantages and disadvantages of each approach in terms of build time, apk size, method count and serialization time.
After this introduction, we deep dive into two topics: First, we look into different serialization strategies available and how they perform. We look into the Gson, Moshi and Kotlinx.serialization libraries and explore their trade-offs when choosing one.
Second, we explain how we built an IntelliJ/Android Studio plugin to help us automate the conversion from AutoValue to Kotlin Data Classes. We explain how plugins work and how you can also develop one to help automate repetitive IDE-related tasks. The sample plugin used in the demo is available at: https://github.com/riclage/ConvertToDataClassPlugin