How to config my proguard-project.txt file to remove just Logs

回眸只為那壹抹淺笑 提交于 2019-11-27 20:46:21
Eric Lafortune

The ProGuard configuration file is split into several parts (as of Android SDK r20), which are specified in project.properties:

  proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

You can only remove logging if optimization is not disabled, which requires a different global configuration file:

  proguard.config=${sdk.dir}/tools/proguard/proguard-android-optimize.txt:proguard-project.txt

The file proguard-project.txt only needs to contain project-specific configuration. Your file seems to contain way too much, but these are the setttings to remove the logging:

-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(...);
}

Similar questions and answers:

If you're stuck with this on Android Studio, the solution of Eric must be applied to your build.grade file (at the app level). Replace:

proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

with:

proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!