I have some questions related to the
kotlin-parcelize
plugin and how best to use it in a modularized project setup:
In an effort to modularize a monolithic Android app module, step 1 (ideally) is to extract common model classes into standalone modules for re-use.
Based on the project setup, we want these new modules to be plain JVM modules (no
com.android.library
plugin).
This becomes problematic if any of the model classes are
Parcelable
and utilize the parcelize plugin -
kotlin-parcelize
can't run in a module without applying the
com.android.library
plugin.
Any recommendations on how to work around this? I can come up with two options myself, but neither one is necessarily ideal; I'm curious if anyone has other ideas or recommendations?
1. Make the common model not Parcelable, create a new Parcelize-specific model class local to the app module, and convert back and forth between the two.
2. Persist the data a different way, or use a different serialization strategy, and remove the
@Parcelize
annotation on those common models.