17

Looking for some help from someone who puts the pro in 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

Jayson Minard
  • 84,842
  • 38
  • 184
  • 227
Bryan
  • 367
  • 3
  • 11
  • Adding a note that we have tried adding the keepclassmembers and we do have keepAttributes `-keepattributes *Annotation*` `-keepclassmembers class ** { @org.jetbrains.annotations.ReadOnly public *; }` – Bryan May 24 '17 at 14:56
  • If this started happening after the Kotlin upgrade, I suggest you file a ticket [on their bug tracking system](https://youtrack.jetbrains.com/issues/kotlin). – m0skit0 May 24 '17 at 16:28

2 Answers2

10

Or a shorter version:

-dontwarn kotlin.reflect.jvm.internal.**

Klemens Zleptnig
  • 1,698
  • 20
  • 36
8

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

These annotations exist in kotlin-compiler which is why proguard can't find them. Just ignore the warning instead of adding kotlin-compiler as a dependency (as this issue suggests Cannot resolve symbol @ReadOnly and @Mutable in Kotlin 1.1.0 compilation).

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

Bryan
  • 367
  • 3
  • 11