https://kotlinlang.org logo
g

grandstaish

08/26/2017, 2:15 AM
I'm trying to debug why Moshi doesn't work with Kotlin + ProGuard. The issue I'm seeing is that when ProGuard is enabled the call
rawType.kotlin.primaryConstructor
returns
null
. What sorts of things do I need to keep in order for kotlin-reflect to be able to find the primary constructor of a class at runtime? Just keeping the
@Metadata
annotation methods (as the library suggests) is not enough. Keeping all kotlin classes (
-keep class kotlin.** { *; }
) does work, but I'd rather just keep what I need.
u

udalov

08/29/2017, 1:26 PM
Try keeping only the entry point to kotlin-reflect and its dependencies:
-keep class kotlin.reflect.jvm.internal.ReflectionFactoryImpl { *; }
g

grandstaish

08/29/2017, 1:42 PM
Didn't work 😞. I also just tried
-keep class kotlin.reflect.** { *; }
and that didn't fix it either, apparently I need to keep something outside of kotlin-reflect 🤔
aha - it was that class + keeping the whole
Metadata
annotation (the readme just says to keep the methods of that annotation)
thank you @udalov
3 Views