Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove all debug logging calls from third-party lib/sdk (Proguard is not working)

I have try many solution e.g. Remove all debug logging calls before publishing: are there tools to do this?

However, When I look in to the logcat. The log still shows. Log from my app is gone but the log from third-party still exist.

This is my proguard config.

-dontwarn **
-target 1.7
#-dontusemixedcaseclassnames
#-dontskipnonpubliclibraryclasses
#-dontpreverify
-verbose

-optimizations !code/simplification/arithmetic,!code/allocation/variable
-keep class **
-keepclassmembers class *{*;}
-keepattributes *

-dontskipnonpubliclibraryclasses
#-dontobfuscate
-forceprocessing
-optimizationpasses 5

-keep class * extends android.app.Activity
-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(...);
}

This is my gradle file config

buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            debuggable false
            jniDebuggable false
            signingConfig signingConfigs.config
        }
        debug {
           proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            minifyEnabled true
            debuggable false
            zipAlignEnabled true
            jniDebuggable false
        }
    }

The customer want to remove every log even the log from Third-party library or SDK for security reason

like image 363
UmAnusorn Avatar asked Oct 20 '25 20:10

UmAnusorn


1 Answers

ProGuard will only be able to remove logging calls in application code, i.e. code that is being processed and included in your own application. Any logging calls being performed by the Android runtime cannot be removed because the runtime is installed on each device and cannot be modified in advance obviously.

Looking at your rules and gradle file, the setup looks correct and also works for me to remove calls to android.util.Log. Ensure that you are using a recent version of ProGuard (e.g. 5.2.1 or later). Also you have ProGuard still disabled in your release buildType, you will need to set minifyEnabled to true to enable it.

like image 96
T. Neidhart Avatar answered Oct 22 '25 09:10

T. Neidhart