2

Is there any way to make kotlin compiler stop adding debug info to compiled classfiles? Something like -g:none argument for javac?

nnesterov
  • 1,232
  • 1
  • 10
  • 27
  • 1
    I had the same problem at work, we ended up using Progard to remove metadata directly from the bytecode. Can't remember the details now but pretty sure it has options to do so. – Renato Aug 27 '21 at 20:03
  • So you are trying to find a way to encrypt the compiled file in not recognizable form ?? – Neelay Srivastava Sep 09 '21 at 05:30

1 Answers1

0

First you need to define the proguard rules on what you want and what you dont want in debug by seeting rules as given here if you have done step one then you will be able to see the code in the debug apk.

Second you need to open the Build Variants window. You can do this by hovering the mouse of the icon in the lower left corner of Android Studio and selecting Build Variants. Then to the right of the app module, click on "debug" and select "release" from the drop down list. Android Studio will now generate a release APK that does not have "debug" in the name.

Note that you will also need to create a keystore so that you can sign your app. Then you will need to configure Android Studio to use your keystore. See Sign Your App for more details about how to do this.

Neelay Srivastava
  • 1,041
  • 3
  • 15
  • 46
  • Thanks for trying to help! But my question isn't related to buildTypes of android app. I'm seeking a way to remove all debug info (local variable table, line table etc) from the kotlin compiler output. – nnesterov Sep 09 '21 at 18:57
  • you want to hide the variables and class that you used ?? – Neelay Srivastava Sep 09 '21 at 23:19
  • I want to remove LineNumberTable (https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.7.12) and LocalVariableTable (https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.7.13) from compiled kotlin classes – nnesterov Sep 10 '21 at 10:02
  • hey I went through this question and came toknow that proguard removes the debug info but you need to define what you want and what you dont want https://stackoverflow.com/questions/39322359/proguard-doesnt-preserve-the-line-numbers-and-method-names-in-stacktrace – Neelay Srivastava Sep 11 '21 at 13:28