Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parcelize annotation in AIDL: Incompatible types: Object cannot be converted to MyCustomObject

I'm rewriting my model class to Kotlin, which has to be Parcelable and used in AIDL:

@Parcelize
data class MyCustomObject(val value1: String, val value2: String) : Parcelable

During compilation it crashes with error:

error: incompatible types: Object cannot be converted to MyCustomObject

and points to this line in generated code:

if ((0!=_reply.readInt())) {
    _result = com.mypackagename.MyCustomObject.CREATOR.createFromParcel(_reply);
}

I used this annotation for other purposes and it was ok, only in AIDL I found mismatch so far.

Any ideas what's wrong?

EDIT: After 5 days with no single comment I've created a ticket for this issue.

like image 709
Yurets Avatar asked Jun 08 '18 10:06

Yurets


1 Answers

It is a bug in Kotlin, so I redirected this issue to JetBrains. You may track it here: KT-25807.

This happens, because createFromParcel() does not return class T, but Object.

UPD

Parcelize annotation is now maintainable by Google and the issue has been fixed in kotlin version 1.5.+ https://issuetracker.google.com/issues/110131003

like image 148
Yurets Avatar answered Nov 20 '22 00:11

Yurets