How to configure proguard to ONLY remove android logging calls

前端 未结 2 1483
抹茶落季
抹茶落季 2020-12-05 08:12

I\'m trying to configure proguard to ONLY remove calls to android.util.Log from my Android app (for the release build). I specifically don\'t want proguard to do any obfusca

2条回答
  •  悲哀的现实
    2020-12-05 08:31

    In build.gradle

    buildTypes {
    
            release {
                minifyEnabled true
                proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            }
        }
    

    In proguard-rules.pro

    -dontwarn **
    -target 1.7
    -dontusemixedcaseclassnames
    -dontskipnonpubliclibraryclasses
    -dontpreverify
    -verbose
    
    -optimizations !code/simplification/arithmetic,!code/allocation/variable
    -keep class **
    -keepclassmembers class *{*;}
    -keepattributes *
    
    #This will not remove error 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(...);
    }
    

提交回复
热议问题