This is normal. Same applies to Gson
# android
d
This is normal. Same applies to Gson
i
Do you have a sample that works with Gson?
d
Sample? No. But it works the same. Also same as in Java.
i
đŸ¤”
k
if you want it to work with proguard and obfuscation turned on then you need to either use the
@SerializedName
annotation in gson or
@JsonName
in moshi
i
Here is one of the model classes I am using -
Copy code
data class Token (
        @Json(name = "client_id") val clientId: String,
        @Json(name = "issued_at") val issuedAt: String,
        @Json(name = "access_token") val accessToken: String,
        @Json(name = "expires_in") val expiresIn: String
)
Without the following in Proguard -
Copy code
-keepclassmembers class com.lianasolutions.progit.models.** {
  <init>(...);
  <fields>;
}

-dontwarn org.jetbrains.annotations.**
-keep class kotlin.Metadata { *; }
the app fails to run with an exception. All of it is discussed in https://github.com/square/moshi/issues/345
I was not raising an issue with
moshi-kotlin
, just sharing what I found while using
moshi
and
moshi-kotlin
d
that’s normal add Proguard rules
It’s not Kotlin specific
i
Have you actually read the issue? It is specific to
moshi-kotlin
and Proguard.
đŸ™„