grandstaish

    grandstaish

    5 years ago
    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.
    udalov

    udalov

    5 years ago
    Try keeping only the entry point to kotlin-reflect and its dependencies:
    -keep class kotlin.reflect.jvm.internal.ReflectionFactoryImpl { *; }
    grandstaish

    grandstaish

    5 years ago
    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