开发者

Disable LogCat output in release apk?

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?


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


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
        }
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜