I have an annotation that I use for a custom mosh...
# squarelibraries
a
I have an annotation that I use for a custom moshi Json Adapter
Copy code
annotation class MyAnnotation(val value: String)
When I try to create the adapter like this
Copy code
moshi.adapter<MyAnnotation>(Int::class.java, MyAnnotation::class.java)
It throws
Copy code
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
Copy code
public abstract java.lang.String com.melegy.moshi.adapters.myannotaion.MyAnnotation.value()
I can create the adapter like this
Copy code
val adapter = moshi.adapter(MyDataClass::class.java)
But I am asking why the first one can’t work.