3

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

Community
  • 1
  • 1
UmAnusorn
  • 10,420
  • 10
  • 72
  • 100
  • This is why external logging tools are on Github, where you can disable loggin just by one method call. Logcat cannot be disabled. Download sample logging tool, refactor the messages to use it, and disable in release version. – R. Zagórski Nov 22 '16 at 09:33
  • The customer want to remove every log even the log from Third-party library or SDK. – UmAnusorn Nov 22 '16 at 09:37
  • ctrl + shif + f > type log.d > and delete the line. – K.Sopheak Nov 22 '16 at 09:49
  • This work only for my sourcecode from my project. But not the log from third-party lib/sdk. – UmAnusorn Nov 22 '16 at 09:53

2 Answers2

2

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.

T. Neidhart
  • 6,060
  • 2
  • 15
  • 38
0

You need to check which kind of logging library your third party using and based on that you can disable the logging for each and every library.

if your third party library use Logger from java like this Logger.getLogger(LIBRARY_CLASS.class.getName()); then you can call like below in application class onCreate():

LogHelper.INSTANCE.setRootLoggerLevel(Level.OFF);

LogHelper class code:

 object LogHelper {

 /**
 * set root logger log level
 *
 * @param level maximum allowed log level[Level]
 */
fun setRootLoggerLevel(level: Level) {
    val rootLogger = LogManager.getLogManager().getLogger("")
    rootLogger.level = level
}
}
Rajesh.k
  • 2,327
  • 1
  • 16
  • 19