[Kotlin] Do not leave debug message in the code

kokchai
1 min readMay 7, 2020

Let’s look at the example below:

val data = "123"
Log.d("debug", "The data is $data")

And the Proguard config is:

-assumenosideeffects class android.util.Log {
public static *** v(...);
public static *** d(...);
public static *** i(...);
public static *** w(...);
public static *** e(...);
}

In the obfuscated code:

StringBuilder sb = new StringBuilder();
sb.append("The data is ");
sb.append("123");
sb.toString();

In the end, Log.d() is gone bu the message is still remained. So the safer way to ensure all those debug message is gone:

if (BuildConfig.DEBUG) {
....
}

Used in:

--

--