如何去掉android log代码

强力去除log, 删除log代码,可以用Proguard的优化来做。 配置如下


-optimizations code/removal/advanced
-optimizationpasses 5

#去掉log4j的log:

-assumenosideeffects class * implements org.slf4j.Logger {
    public *** trace(...);
    public *** debug(...);
    public *** info(...);
    public *** warn(...);
    public *** error(...);
}

#去掉android原生log:

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

参考文档:


 http://proguard.sourceforge.net/manual/usage.html#optimizationoptions
 http://proguard.sourceforge.net/manual/examples.html#logging
 http://proguard.sourceforge.net/index.html#/manual/optimizations.html

你可能感兴趣的:(如何去掉android log代码)