ahmad
05/10/2020, 9:53 PMannotation class MyAnnotation(val value: String)
When I try to create the adapter like this
moshi.adapter<MyAnnotation>(Int::class.java, MyAnnotation::class.java)
It throws
java.lang.IllegalArgumentException: interface com.melegy.moshi.adapters.myannotaion.MyAnnotation must not declare methods.
The exception is thrown from here
https://github.com/square/moshi/blob/master/moshi/src/main/java/com/squareup/moshi/Types.java#L306
When I debug to see what methods does this mean I found that the method is the parameter in the annotation
public abstract java.lang.String com.melegy.moshi.adapters.myannotaion.MyAnnotation.value()
I can create the adapter like this
val adapter = moshi.adapter(MyDataClass::class.java)
But I am asking why the first one can’t work.