4

I'm currently making a module using Kotlin-reflect. When I try to build a binary as a release mode, there is no proguard error, but module is not working.

instance::class.memberProperties.forEach {

    val name = it.annotations.find { annotation -> annotation is Property}
        ?.let { property -> (property as Property).name }
        ?:it.name

    attributeMap[name].let { value ->

        if (value != null && (it is KMutableProperty<*>)) {
            // Log message is not printed after this line.
            it.setter.call(instance, value)
        } else if (value == null) {
            propertyNameMap[it.name] = name
        }
    }
}

I'd set proguard-rules.pro file like this. (https://github.com/square/moshi/issues/402)

-keep interface kotlin.reflect.jvm.internal.impl.builtins.BuiltInsLoader
-keep class kotlin.reflect.jvm.internal.impl.serialization.deserialization.builtins.BuiltInsLoaderImpl
Kyoung-june Yi
  • 503
  • 1
  • 3
  • 16
  • 1
    This Reddit post might be relevant: [(Proguard, Kotlin) Preserving Kotlin reflect class - how?](https://www.reddit.com/r/androiddev/comments/aoiqvk/proguard_kotlin_preserving_kotlin_reflect_class/) – Steven Jeuris Jan 24 '20 at 10:43

0 Answers0