4

I have two versions of the same application using identical proguard.cfg with the following section aimed at squelching all Log.x() LogCat output:

-assumenosideeffects class android.util.Log {
    public static *** v(...);
    public static *** i(...);
    public static *** d(...);
    public static *** w(...);
    public static *** e(...);
}

The first version is monolithic (i.e. not referencing any Library projects whatsoever) and proguard.cfg works there exactly as expected.

The second version is using two Library projects (one is mine and the other is Google's LVL). The same proguard.cfg is placed in both the application project and my Library project. However, in that second version, proguard.cfg seems to simply have no effect!

What could possibly explain this?

an00b
  • 11,338
  • 13
  • 64
  • 101

3 Answers3

2

You did add proguard.config=proguard.cfg to build.properties in your application project? You should see ProGuard's console messages and output files. The optimization pass should at least mention some "Number of removed instructions".

The application classes and the library classes are all compiled to bin/classes. They are then treated exactly the same: they are combined into bin/original.jar and obfuscated to bin/obfuscated.jar, using proguard.cfg. Adding more classes can't really have an effect on removing the logging code.

Eric Lafortune
  • 45,150
  • 8
  • 114
  • 106
  • +1 already, since you prompted me to compare `default.properties` between the Library project and the application project. Sure enough, this line exists in the Library project but doesn't exist in the application project! Yet another pitfall on the way to moving from a monolithic project to Library based projects.... I will test the change shortly and accept if this turns out to be the culprit. – an00b Jun 30 '11 at 09:46
  • Just tested your suggestion (adding `proguard.config=proguard.cfg` to the **application's** project as well) and... it works! :) – an00b Jun 30 '11 at 10:04
1

Please use this switch to diagnose: -whyareyoukeeping

Kevin Yuan
  • 1,008
  • 8
  • 20
0

To disable logging in my app, I used this:

-assumenosideeffects public class android.util.Log {
    <methods>;
}

If that doesn't solve your problem then there are a couple other things to try:

  1. Throw an exception at a part of the code proguard should be obfuscating. If the stacktrace is not obfuscated, then proguard might not be running properly.
  2. Your app cannot have debug enabled when you do a proguard build. Be sure that in your manifest, the <application> element is set to android:debuggable="false"
plowman
  • 13,335
  • 8
  • 53
  • 53
  • Thanks for the attempt to help. There isn't any `android:debuggable="false"` in neither my Library project nor my Application project and yet Proguard works after applying @Eric Lafortune's suggestion. – an00b Jun 30 '11 at 10:03