I'm trying to use AutoValueGsonTypeAdapterFactory but the class is never generated. Here is my implementation.
@AutoValue
public abstract class Foo {
public abstract String bar();
@SerializedName("Baz") abstract String baz();
public abstract int quux();
public static TypeAdapter<Foo> typeAdapter(Gson gson) {
return new AutoValue_Foo.GsonTypeAdapter(gson);
}
}
//Gson
compile "com.google.code.gson:gson:2.8.0"
//AutoValue
apt "com.google.auto.value:auto-value:1.3"
apt "com.ryanharter.auto.value:auto-value-gson:0.4.5"
provided "com.ryanharter.auto.value:auto-value-gson:0.4.5"
The typeAdapter method has a warning "never used" and AutoValueGsonTypeAdapterFactory is never generated
Seems that the
AutoValueGsonTypeAdapterFactory
is autogenerated until version 0.4.0.Now the suggested approach is to create a single implementation of
TypeAdapterFactory
for all of yourauto-value-gson
classes annotated with@GsonTypeAdapterFactory
. Read theauto-value-gson
docs.