Zordid
Zordid

Reputation: 10469

Trying to use Proguard to remove logging fails and leads to Dalvik error code 1

I got a simple question: from several sources I learned that using Proguard to remove calls to the Andriod logging framework using the optimization steps "assumenosideeffects" is a very clean and easy way.

I wanted to get rid of all my if's in my code related to if-logging-is-on.

But then:

  1. I learned I have to switch to proguard-android-optimize.txt settings for optimizations to work.
  2. Already there, a warning states that Dex does not like Proguard to fiddle with the code!
  3. It does not work. I get a Dalvik error, I guess that's exactly why it is not recommended to use Proguard's optimization features.

But then: why on earth do I encounter all these "helpful" ideas to go the Proguard way of removing log calls? Has it been working in the past? Can I do anything to make it work? Because I really like the idea of cleaning my code, removing all the useless String constants only used for logging, etc.

Upvotes: 0

Views: 255

Answers (1)

Eric Lafortune
Eric Lafortune

Reputation: 45648

ProGuard generally works fine, but it's always possible that you've run into a bug. You should check that you are using the latest version -- ProGuard 4.10 at this time of writing. You should see the version in the console log, or by typing

java -jar android-sdk/tools/proguard/lib/proguard.jar

The Android SDK often doesn't come with the latest version, but you can manually replace the jar with a recent copy from the ProGuard site. All versions are backward compatible.

Upvotes: 2

Related Questions