Reputation: 7159
I was reading the docs about shrinking, obfuscating and optimising for a release build using build.gradle for an Android app. In one section of the docs, proguard-android.txt
is used as the defauly ProGuard file:
android {
...
buildTypes {
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
and in another section, proguard-android-optimize.txt
is used:
android {
...
buildTypes {
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),
'proguard-rules.pro'
}
}
}
There doesn't seem to be an explanation of what the difference between these are, and I can't find any information. Can someone explain what the differences are and when you would use proguard-android-optimize.txt
vs proguard-android.txt
?
Thanks :)
Upvotes: 43
Views: 18857
Reputation: 1534
Take a look at the Android source code over here.
Optimizations: If you don't want to optimize, use the proguard-android.txt configuration file instead of this one, which turns off the optimization flags. Adding optimization introduces certain risks, since for example not all optimizations performed by ProGuard works on all versions of Dalvik. The following flags turn off various optimizations known to have issues, but the list may not be complete or up to date. (The "arithmetic" optimization can be used if you are only targeting Android 2.0 or later.) Make sure you test thoroughly if you go this route.
Also, this answer is a pretty good read as well.
Upvotes: 30