According to Google, I must \"deactivate any calls to Log methods in the source code\" before publishing my Android app to Google Play. Extract from section 3 of th
If you can run a global replace (once), and after that preserve some coding convention, you can follow the pattern often used in Android framework.
Instead of writing
Log.d(TAG, string1 + string2 + arg3.toString());
have it as
if (BuildConfig.DEBUG) Log.d(TAG, string1 + String.format("%.2f", arg2) + arg3.toString());
Now proguard can remove the StringBuilder and all strings and methods it uses on the way, from optimized release DEX. Use proguard-android-optimize.txt
and you don't need to worry about android.util.Log in your proguard-rules.pro
:
android {
…
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
With Android Studio gradle plugin, BuildConfig.DEBUG
is quite reliable, so you don't need extra constants to control the stripping.