Reputation: 2108
we have a big project cant delete lot of debug messages and project is in release stage.we want to disable all debug messages in our projects.the debug message format is
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.d("Gajanand", "onCreate: just check");
}
i tried with
Android:debuggable="false"
but its not working and also tried to change build variant to release but getting many errors not able to build project .please any help
Upvotes: 0
Views: 466
Reputation: 9026
You could use the following proguard-rule in order to ignore all Debug and Verbose Logs in a release:
# ignore all Debug and Verbose Logs in a release
-assumenosideeffects class android.util.Log {
public static *** d(...);
public static *** v(...);
}
So you dont have to "disable" all your Logs manually - they get just obfuscated.
In order to apply this proguard rule you have to use the optimization function of proguard by modifying your gradle file:
buildTypes {
release {
shrinkResources false
minifyEnabled true
zipAlignEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),
'proguard-rules.pro'
signingConfig signingConfigs.config
proguardFile '/<your-custom-file>/app/proguard-rules.pro'
debuggable false
}
}
Also have a look in the proguard manual: https://www.guardsquare.com/en/proguard/manual/usage
Upvotes: 1
Reputation: 81
For my project I was able to get rid of the debug messages with the following.
First I went to the proguard-rules.pro file that should be near your build.gradle file. In that file I added:
-assumenosideeffects class android.util.Log { public static * d(...); }
Then I went to the build.gradle file and added:
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),
'proguard-rules.pro'
}
}
For more info go here.
Upvotes: 1
Reputation: 1
you can do the hard way and use remplace " Ctr + shift + r " and remplace all the "log." by " // " to put in comment all the log request.
Upvotes: 0