9

I see some unexplained Proguard behaviour.

AFAIK proguard does not pay attention to android manifest. Also, in my proguard.cfg I have no mention of BroadcastReceiver related classes. So I assume that those should be stripped out.

However I see something strange in bin/proguard.txt:

# view AndroidManifest.xml #generated:784
-keep class com.fiksu.asotracking.InstallTracking { <init>(...); }

and that class (descendand of BroadcastReceiver) does not get stripped. Reason does not say anything meaningful to me:

[proguard] com.fiksu.asotracking.InstallTracking
[proguard]   is kept by a directive in the configuration.

If class is not mentioned in manifest, it gets stripped.

Would be great to know why.

lstipakov
  • 3,138
  • 5
  • 31
  • 46
  • Have you checked `/tools/proguard/proguard-android.txt`. That usually contains the declarations that prevents Proguard from completely murdering your application. – Jens Oct 04 '13 at 12:42
  • Yep, to my understanding it does not contain anything related to BroadcastReceivers or manifest, or I interpret it wrongly. – lstipakov Oct 04 '13 at 12:48
  • The sdk definition usually contains something like this: `-keep public class * extends android.content.BroadcastReceiver` that prevents receivers from being mangled. – Jens Oct 04 '13 at 12:51

1 Answers1

10

The build process runs the tool aapt to automatically create the configuration file bin/proguard.txt, based on AndroidManifest.xml and other xml files. The build process then passes the configuration file to ProGuard. So ProGuard itself indeed doesn't consider AndroidManifest.xml, but aapt+ProGuard do.

Eric Lafortune
  • 45,150
  • 8
  • 114
  • 106
  • Thanks, Eric! Does it also mean that we do not need anymore to manually add "keep" directives for broadcast receivers, services and so on? – lstipakov Oct 05 '13 at 07:11
  • @Stipa That's correct. The default configuration inside the SDK should provide all generic settings, and aapt should create all application-specific configuration (except application-specific reflection). – Eric Lafortune Oct 07 '13 at 23:16