Kotlin 2.0 Compatibility: Unable to Instantiate Message #5859
-
Hi Stream team, I'm currently upgrading my project to use Kotlin 2.0 with the K2 compiler, and I’ve encountered a compatibility issue with the Stream Chat Android SDK (v5.x). Previously, I was constructing messages like this:
It seems like the model class has @InternalStreamChatApi annotation.on it. But under Kotlin 2.0, this now fails to compile with the following error:
What is a guidance on a work around for this? Tried upgrading to 6.4.0 but still getting this error. We are currently using stream 5.5.0 and we are using the low level client not the compose one. (might be time for an update hahah) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hi @Polar-Points , Thank you for the report! Best regards, |
Beta Was this translation helpful? Give feedback.
-
@VelikovPetar Thanks for getting back to me! This is what I am seeing. I have attached screenshots. Note that I have updated from 5.5.0 -> 5.17.23, which seems to be the last published version for version 5. ![]() ![]() I do see that this is marked internal, not sure if this little line would have set off the k2 compiler
|
Beta Was this translation helpful? Give feedback.
Hi @Polar-Points,
Thanks for the details - You are correct, I did some tests and the
Message
model is considered asInternalStreamChatApi
because thechannelInfo
property and theChannelInfo
model are also marked withInternalStreamChatApi
.I am not sure if upgrading the SDK version to a newer one is a feasible option for you (since v6.0.0 the
channelInfo
is no longer internal), but if not, you should be able to use@OptIn(InternalStreamChatApi::class)
on the enclosing class where you instantiate theMessage
object, which would suppress the error/warning. It is perfectly safe to instantiate theMessage
object - it is just not advised to read thechannelInfo
member. Because it is marked as…