2

I have so far implemented a Parcelable class with AutoValue and now I'd like to be able to deserialize it Gson.

So I have found the AutoValue Extension named auto-value-gson and I have tried to implement a class just like the examples on the github page.

So my class changed to :

@AutoValue
public abstract class UploadPhotoResponse implements Parcelable{
    public abstract String getError();
    public abstract UploadPhotoResponseNestedItem getPost();

    public static Builder builder() {
        return new AutoValue_UploadPhotoResponse.Builder();
    }

    @AutoValue.Builder
    public static abstract class Builder {
       public abstract Builder setError(String error);
       public abstract Builder setPost(UploadPhotoResponseNestedItem post);

       public abstract UploadPhotoResponse build();
    }

// This is the new code I have added 
   public static TypeAdapter<UploadPhotoResponse> typeAdapter(Gson gson) {      
        return new AutoValue_UploadPhotoResponse.GsonTypeAdapter(gson);
    }

}

but I'm getting error : "Cannot resolve symbol GsonTypeAdapter"

I'm using the following dependencies (just in case something is missing) :

provided 'com.google.auto.value:auto-value:1.3'
apt 'com.google.auto.value:auto-value:1.3'
apt 'com.ryanharter.auto.value:auto-value-parcel:0.2.5'
apt 'com.ryanharter.auto.value:auto-value-gson:0.4.5'
provided 'com.ryanharter.auto.value:auto-value-gson:0.4.5'
annotationProcessor 'com.gabrielittner.auto.value:auto-value-with:1.0.0'
mt0s
  • 5,781
  • 10
  • 42
  • 53
  • Do you get different errors before for `AutoValue_UploadPhotoResponse`. If you try to clean the project. – tynn Jan 18 '17 at 14:26
  • 1
    Clean project did the job! – mt0s Jan 18 '17 at 14:34
  • In case anyone else is struggling, in my case my IDE auto imported a different `TypeAdapter` and thus faced this problem even after having the static method mentioned in the document. It worked once I ensured the correct import i.e. `import com.google.gson.TypeAdapter` – rpattabi Oct 02 '17 at 10:53

0 Answers0