E
E
Evgeny Bykov2019-06-27 16:51:24
Android
Evgeny Bykov, 2019-06-27 16:51:24

Android how to remove logging?

Log.* - does not make sense in the release version, only slightly loads the system. To get rid of the logs, I saw this check: if (BuildConfig.DEBUG) {} . Maybe my question is stupid, but is there a way to automatically remove the call to all logs in the project? (After all, doing the check also takes some time, even nanoseconds)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
illuzor, 2019-06-27
@BOOMeranGG

Use proguard/r8.
In the proguard-rules.pro file write the following:

-assumenosideeffects class android.util.Log {
    public static boolean isLoggable(java.lang.String, int);
    public static int println(...);
    public static int v(...);
    public static int i(...);
    public static int w(...);
    public static int d(...);
    public static int e(...);
    public static int wtf(...);
}

Details here in the section Removing logging code

I
IdeSade, 2019-07-06
@IdeSade

if (BuildConfig.DEBUG) {} the compiler will remove this code itself, there will be no check

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question