正在寻求将职业选手放入proguard的人的帮助.

Annotations used by kotlin-reflect (required dependency for jackson-module-kotlin v v2.8.8) are getting stripped out after upgrading to kotlin 1.1.2-3. The error from proguard is: Warning:kotlin.reflect.jvm.internal.impl.descriptors.CallableDescriptor: can't find referenced class org.jetbrains.annotations.ReadOnly

This is happening for a few annotations, not just ReadOnly. We have tried adding a good ol' catch all but the error still exists:

-keep class org.jetbrains.kotlin.** { *; }
-keep class org.jetbrains.annotations.** { *; }
-keepclassmembers class ** {
  @org.jetbrains.annotations.ReadOnly public *;
}

Looking at the source for ReadOnly it is an @interface with java.lang.annotations.* imported for @Documented, @RetentionPolicy.CLASS, @Target

推荐答案

The fix for us was to add dontwarn for the reflect warnings.

-dontwarn kotlin.reflect.jvm.internal.impl.descriptors.CallableDescriptor
-dontwarn kotlin.reflect.jvm.internal.impl.descriptors.ClassDescriptor
-dontwarn kotlin.reflect.jvm.internal.impl.descriptors.ClassifierDescriptorWithTypeParameters
-dontwarn kotlin.reflect.jvm.internal.impl.descriptors.annotations.AnnotationDescriptor
-dontwarn kotlin.reflect.jvm.internal.impl.descriptors.impl.PropertyDescriptorImpl
-dontwarn kotlin.reflect.jvm.internal.impl.load.java.JavaClassFinder
-dontwarn kotlin.reflect.jvm.internal.impl.resolve.OverridingUtil
-dontwarn kotlin.reflect.jvm.internal.impl.types.DescriptorSubstitutor
-dontwarn kotlin.reflect.jvm.internal.impl.types.DescriptorSubstitutor
-dontwarn kotlin.reflect.jvm.internal.impl.types.TypeConstructor

这些注释存在于kotlin编译器中,这就是proguard找不到它们的原因.只需忽略警告,而不是将kotlin编译器添加为依赖项(正如本期建议的那样).

This may be a bug in kotlin-reflect; they should provide proguard rules to hide this from integrating apps.

Kotlin相关问答推荐

在Kotlin Jetpack中重用下拉菜单

在Kotlin 有更好的结合方式?

Kotlin Coroutine()是如何工作的?S阻止了.

扩展属性委托给实例属性

Kotlin 基于参数类型的返回类型推断

使用调度程序运行异步 Kotlin 代码

有没有什么方法或算法可以在没有存储的情况下生成唯一的随机数?

init中的NPE抽象函数变量

Kotlin:我可以将函数分配给 main 的伴随对象中的变量吗?

Kotlin 可空泛型

如果不在可组合函数中,如何获取 stringResource

使用 LazyListScope 嵌套可组合项

Kotlin的web-framework框架

Kotlin-通过与属性列表进行比较来筛选对象列表

禁用 IntelliJ kotlin * 导入?

Kotlin通过映射委托属性,如果映射中不存在,则抛出NoTouchElementException

Kotlin中的Memoization功能

Kotlin Android:属性委托必须有一个 'getValue(DashViewModel, KProperty*>)' 方法

安装 Kotlin-Jupyter:e: java.lang.NoClassDefFoundError: 无法初始化类 org.jetbrains.kotlin.com.intellij.pom.java.LanguageLevel

Failure delivering result on activity result