parceler: Error:(63, 119) error: incompatible types: Object cannot be converted to String

Hi,

Parceler was working fine here for a long time, yet recently I started to face

Error:(63, 119) error: incompatible types: Object cannot be converted to String

trying to compile generated code with recent Android Studio and build tools.

It complains about write() implementation, pointing at the for loop:

public static void write(...Model domain$$1, android.os.Parcel parcel$$1, int flags$$0, IdentityCollection identityMap$$0) {
    int identity$$0 = identityMap$$0 .getKey(domain$$1);
    if (identity$$0 != -1) {
        parcel$$1 .writeInt(identity$$0);
    } else {
    	  [...]
        if (...BaseModel$$PackageHelper.accessBaseModel$FG$mTags(domain$$1) == null) {
            parcel$$1 .writeInt(-1);
        } else {
            parcel$$1 .writeInt(...BaseModel$$PackageHelper.accessBaseModel$FG$mTags(domain$$1).size());

            // compiler complains about the line below, IDE underlines `java.lang.String string$$0`
            for (java.lang.String string$$0 : ...BaseModel$$PackageHelper.accessBaseModel$FG$mTags(domain$$1)) {
                parcel$$1 .writeString(string$$0);
            }
        }
        [...]
    }
}

IDE underlines java.lang.String string$$0 of the following line:

for (java.lang.String string$$0 : ...BaseModel$$PackageHelper.accessBaseModel$FG$mTags(domain$$1)) {

Versions:

  • buildToolsVersion ‘25.0.3’
  • Android Studio 3.0 Canary 3
  • parceler: 1.1.8
  • com.android.tools.build:gradle:3.0.0-alpha3

And in fact mTags is ArrayList.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 16 (8 by maintainers)

Most upvoted comments

I updated the project to use 1.1.9 but it makes no difference here. I still face Error:(63, 119) error: incompatible types: Object cannot be converted to String

I also did project clear, sync with gradle. Anything missing?