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

前端 未结 2 692
被撕碎了的回忆
被撕碎了的回忆 2020-12-05 15:53

This is the code i am using right now in the proguard-project.txt

# This is a configuration file for ProGuard.
# http://proguard.sourceforge.net/index.html#m         


        
相关标签:
2条回答
  • 2020-12-05 16:19

    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:

    • Removing Log call using proguard
    • Removing unused strings during ProGuard optimisation
    • Removing logging with ProGuard doesn't remove the strings being logged
    0 讨论(0)
  • 2020-12-05 16:36

    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'
    
    0 讨论(0)
提交回复
热议问题