Hi there, I've been using `org.jetbrains.kotlin:k...
# serialization
r
Hi there, I've been using
org.jetbrains.kotlin:kotlin-serialization
in some of my Android projects for a while, and I recently encountered an issue after enabling K2 mode on Android Studio. I started to see errors on all my classes annotated with
@Serializable
. The error looks like a lint error related to a missing opt-in annotation:
This declaration is opt-in and its usage should be marked with @kotlinx.serialization.InternalSerializationApi
However, it still doesn't make much sense to me. The application builds and runs fine without any issues, so I assume it could be an Android Studio K2 mode issue. However, as the
InternalSerializationApi
has been always marked as
@RequiresOptIn(level = RequiresOptIn.Level.ERROR)
, it seems like I should always have added the opt-in annotation, and I wasn't aware of, and only after K2 started to prompt errors, which is weird. After reading the kdocs of the
InternalSerializationApi
, I am concerned that my app could start crashing after any updates. I am only using basic JSON serialization/deserialization and not any custom serializer or functionalities. It seems that the issue is related to the
$serializer
property generated by the plugin, but I am unsure about what else is marked as
InternalSerializationApi
or what will be affected by an internal API, potentially causing future crashes. Initially, I thought it would be only related to sealed classes, but I also see that happening with data classes and normal classes. Funny that objects don't present the same error. I can definitely annotate my
Serializable
types with the
@InternalSerializationApi
, however, that seems awkward... Am I missing something? Thanks for the help
I missed adding the versions I'm using: Kotlin: 2.0.20 kotlin-serializable: 1.7.3