Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable LogCat output in release apk?

Tags:

android

logcat

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?

like image 748
Android Eve Avatar asked Apr 01 '11 14:04

Android Eve


People also ask

What is Logcat output?

Logcat is a command-line tool that dumps a log of system messages, including stack traces when the device throws an error and messages that you have written from your app with the Log class. This page is about the command-line logcat tool, but you can also view log messages from the Logcat window in Android Studio.

How do I stop Logcat from clearing?

Prevent clearing the log when the app crashes By default when the app got crashed the logcat clear's in the android studio. To prevent this, click the right end chooser(Filter Configuration chooser) in the logcat tab then select Edit Filter Configuration option and enter current app name and package name.

Why do you use Logcat in Android Studio?

The Logcat window in Android Studio displays system messages, such as when a garbage collection occurs, and messages that you added to your app with the Log class. It displays messages in real time and keeps a history so you can view older messages.


2 Answers

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

like image 126
Ravi Vyas Avatar answered Sep 18 '22 21:09

Ravi Vyas


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
        }
    }
like image 36
ChinLoong Avatar answered Sep 20 '22 21:09

ChinLoong