Data Class in Kotiln must have a variable/value parameter in it's constructor declaration.
Official doc states that :
To ensure consistency and meaningful behavior of the generated code,
data classes have to fulfill the following requirements:
The primary constructor needs to have at least one parameter;
All primary constructor parameters need to be marked as val or var;
Data classes cannot be abstract, open, sealed or inner;
(before 1.1) Data classes may only implement interfaces.
So, your data class should be something similar like below :
data class Foo(
val bar: Any
)
Note: In Kotlin, you can declare class constructor just by placing '()' following by class name to make it as primary constructor.
You class declaration should be something like below :
data class Country(
@SerializedName("name")
val countryName: String?,
@SerializedName("capital")
val capital: String?,
@SerializedName("flagPNG")
val flag: String?
)
Refer here for more info.