How to remove all debug logging calls before building the release version of an Android app?

前端 未结 27 1821
有刺的猬
有刺的猬 2020-11-22 07:39

According to Google, I must \"deactivate any calls to Log methods in the source code\" before publishing my Android app to Google Play. Extract from section 3 of th

27条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-22 08:18

    This is how I solve it in my Kotlin Project before going to production:

    buildTypes {
            release {
                minifyEnabled true
                proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            }
        }
    
    -assumenosideeffects class android.util.Log {
        public static boolean isLoggable(java.lang.String, int);
        public static int d(...);
        public static int w(...);
        public static int v(...);
        public static int i(...);
        public static int e(...);
    }
    

提交回复
热议问题