Proguard removes kotlin directory in Android APK

Hi all,

I’m running an application that does not use Kotlin, but my dependencies do. From what I understand, using Kotlin will result in a “kotlin” directory in the root of the APK.

When I enable Proguard, this folder, along with some others such as “java”, “com”, etc are all removed, and when Kotlin code is executed during runtime, I see a crash

12-02 16:59:47.539  1270  1502 E AndroidRuntime: java.lang.AssertionError: Built-in class kotlin.Any is not found
12-02 16:59:47.539  1270  1502 E AndroidRuntime:    at kotlin.reflect.jvm.internal.impl.builtins.KotlinBuiltIns$3.invoke(KotlinBuiltIns.java:113)
12-02 16:59:47.539  1270  1502 E AndroidRuntime:    at kotlin.reflect.jvm.internal.impl.builtins.KotlinBuiltIns$3.invoke(KotlinBuiltIns.java:108)

I’ve configured my rules to literally keep everything, but the base folders in the APK gets removed. I’ve also tried with -keepdirectories, but same issue happens

-dontobfuscate
-dontoptimize
-dontshrink
-addconfigurationdebugging
-dontpreverify
-dontwarn ***

-keep class *** { *** *; <methods>; <init>(...);}
-keep interface *** { *** *; }
-keep @interface *** { *** *; }
-keep enum *** { *** *; }
-keepattributes ***
-optimizations !code/simplification/arithmetic,!code/simplification/cast,!code/allocation/variable,!field/*,!class/merging/*,!method/removal/*,!class/unboxing/enum

Please shed some light on how those folders are generated, and how I can configure them to not be removed. Thank you

Dear @JasonS ,

First of all, welcome to our community!

To further help you tackle this issue, could you please share a sample project that shows the problem?

Kind regards,

Ewout

I would suggest to enable Kotlin in your app, probably it would be enough to add to build.gradle

apply plugin: 'kotlin-android'
1 Like

I have tried adding Kotlin to my application, but the same issue occurs

Dear @JasonS ,

Thanks for your update. If you are able to do so, please share a sample project so that we can test this on our side and update you asap.

Kind regards,

Ewout

Dear @alexcohn ,

Welcome to our community and thank you for your help here!

Kind regards,

Ewout