我目前正在使用 Kotlin-reflect 制作一个模块。当我尝试将二进制文件构建为发布模式时,没有 proguard 错误,但模块无法正常工作。
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
}
}
}
我会像这样设置 proguard-rules.pro 文件。( 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