Gson, Kotlin and Proguard is crashing my app!

Raymond Chan
Oct 23, 2018

--

Lately I have been working with Kotlin, the code base is mixed with Java and Kotlin. One of the issues I found is that when Java Gson model is turned to Kotlin, the app crashes. With not much idea in head, I have done something like this:

data class Message(@JvmField val address, @JvmField val content)

It works🎉! The trick is by adding @JvmField annotation in front of class members.

My guess is that by adding @JvmField annotation, it keeps the field in public in Java level. However, I am not able to replicate the issue in a completely new project. Any ideas?🤔

--

--