7

Short of diligently commenting out the numerous Log.v() and Log.d() statements I planted throughout an app I have written, is there a more elegant/efficient way of compiling an app to a "release mode", so that my LogCat messages don't show up?

Android Eve
  • 14,864
  • 26
  • 71
  • 96

2 Answers2

5

Please check this thread : How do I enable/disable log levels in Android?

Community
  • 1
  • 1
Ravi Vyas
  • 12,212
  • 6
  • 31
  • 47
1

Using the latest Android Studio 2.1.3 at this moment, I followed the steps below:

Add the lines below in proguard-rules.pro

-assumenosideeffects class android.util.Log {
    *;
}

Edited build.gradle of app module. minifyEnabled has to be set to true to activate proguard. proguard-android-optimize.txt has to be used, in order to allow optimisations in proguard-rules.pro to run.

buildTypes {
        release {
            minifyEnabled true  
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 
            signingConfig signingConfigs.config
        }
    }
ChinLoong
  • 1,735
  • 24
  • 26
  • 1
    In comments to accepted answer (http://stackoverflow.com/questions/2446248/remove-all-debug-logging-calls-before-publishing-are-there-tools-to-do-this) it is said that line numbers will be broken as Log calls will be removed. – CoolMind Feb 03 '17 at 12:10