Android XML parsing using retrofit

146 Views Asked by At

Getting this error : java.lang.RuntimeException: org.simpleframework.xml.core.MethodException: Annotation @org.simpleframework.xml.Element(data=false, name=, required=false, type=void) must mark a set or get method

1

There are 1 best solutions below

0
MexiCano On

This is the same problem as: kotlin data class + bean validation jsr 303

You need to use Annotation use-site targets since the default for an annotation on a property is prioritized as:

parameter (if declared in constructor) property (if the target site allows, but only Kotlin created annotations can do this) field (likely what happened here, which isn't what you wanted). Use get or set target to place the annotation on the getter or setter. Here it is for the getter:

@Root(name = "response")
public class User() {
    @get:Element public var result: String? = null
    @get:Element public var token: String? = null
    @get:Element public var uid: String? = null
}

See the linked answer for the details.

See the question response: Here