I am trying to figure out how ProGuard works in an Android project built with Gradle.
Given my Gradle DSL:
buildTypes {
debug {
versionNameSuffix = ".D"
}
release {
}
all {
minifyEnabled = true
proguardFile "proguard-configur.txt"
}
}
And given my proguard-configur.txt file:
# Allow obfuscation of android.support.v7.internal.view.menu.**
# to avoid problem on Samsung(and other) 4.2.2 devices with appcompat v21
# see https://code.google.com/p/android/issues/detail?id=78377
-optimizations !class/merging/*,!code/allocation/variable
-keepattributes **
-keep class !android.support.v7.internal.view.menu.**,** {*;}
-keep class !android.support.** {*;}
-dontpreverify
-dontwarn **
The behaviour I would expect here is to keep all classes but the support library, therefore, the support library would be obfuscated and optimized. Nevertheless, it is not optimized and doesn't seem to be obfuscated either:
<root>: 64710
<default>: 1
android: 15856
accessibilityservice: 6
accounts: 23
animation: 38
app: 437
appwidget: 7
bluetooth: 2
content: 397
pm: 85
res: 95
database: 91
sqlite: 23
graphics: 275
drawable: 85
shapes: 2
pdf: 3
hardware: 4
display: 3
location: 35
media: 200
session: 72
net: 62
http: 6
wifi: 6
os: 236
preference: 22
print: 22
pdf: 5
provider: 15
speech: 6
tts: 6
support: 12406
annotation: 3
v4: 7030
accessibilityservice: 41
app: 1438
content: 232
pm: 1
res: 8
database: 3
graphics: 122
drawable: 96
hardware: 19
display: 19
internal: 74
view: 74
media: 1108
routing: 96
session: 766
net: 64
os: 21
print: 82
provider: 96
speech: 14
tts: 14
text: 88
util: 265
view: 2290
accessibility: 847
widget: 1072
v7: 5373
app: 458
appcompat: 15
cardview: 8
gridlayout: 7
internal: 2172
app: 267
text: 3
transition: 2
view: 608
menu: 512
widget: 1290
recyclerview: 1
view: 25
widget: 2687
telephony: 4
text: 53
method: 3
style: 4
transition: 16
util: 66
view: 807
accessibility: 164
animation: 35
inputmethod: 3
webkit: 73
widget: 553
So, the question is clear: Why is not android.support and descendants obfuscated and optimized?
I think it should be
minifyEnabled true
notminifyEnabled = true
at least it is like this in my build.gradle file and obfuscation works.