Proguard ignoring -assumenosideeffects while exporting Export Signed Application Package

1,427 views
Skip to first unread message

raj

unread,
Apr 18, 2012, 5:44:57 PM4/18/12
to adt...@googlegroups.com
Windows 7
SDK r18
ADT - 18.0.0.v201203301601-306762
Eclipse - 3.7.2

Using instructions from proguard.properties with proguard-project.txt :
wrote
-assumenosideeffects class android.util.Log {
    public static int d(...);
    public static int w(...);
    public static int i(...);
}

to strip Logs from release version of the app, NOT working

Previously ( SDK r17, ADT - 17.0.1) used
proguard.config=proguard.cfg

where proguard.cfg contained
-assumenosideeffects class android.util.Log {
    public static int d(...);
    public static int w(...);
    public static int i(...);
}
which worked fine.

Kindly suggest.




Tor Norbye

unread,
Apr 18, 2012, 6:09:26 PM4/18/12
to adt...@googlegroups.com
What's in your project.properties file?

Mateo Ortega

unread,
Apr 18, 2012, 8:45:22 PM4/18/12
to adt-dev
I'm running into this too, the night before we are set to release.

-From http://proguard.sourceforge.net/index.html#manual/usage.html, it
says --assumenosideffects is "Only applicable when optimizing".
-${sdk.dir}/tools/proguard/proguard-android.txt says:
"Optimization is turned off by default. Dex does not like code run
# through the ProGuard optimize and preverify steps".

It seems either I have to manually code them out with a static
variable of some sort (If Logging {Log.D}) OR turn on optimization,
overriding defaults and re-test the App to make everything is kosher?
Maybe there is another option? Did I mention we were set to release
tomorrow. :/

Thanks in advance,
Mateo

Tor Norbye

unread,
Apr 18, 2012, 8:56:39 PM4/18/12
to adt...@googlegroups.com
I wouldn't turn on optimization the night before shipping if you
haven't tested that thoroughly.

You're probably better off adding if (BuildConfig.DEBUG) around your
Log calls; just like the R class BuildConfig is generated at build
time and DEBUG will be set to false (as a constant) for release builds
so the compiler will strip out the full body of the logging call.

This should be a much safer change to make right before shipping (and
hopefully you don't have a million logging calls everywhere; just
strip out the most frequent ones).

-- Tor

raj

unread,
Apr 19, 2012, 9:38:14 AM4/19/12
to adt...@googlegroups.com
Thanks for the advice - found the difference in tools\proguard\proguard-android.txt where optimization is turned off by default.
Will use if (BuildConfig.DEBUG) for Logging.

-raj

Raphaël Moll

unread,
Apr 19, 2012, 2:47:41 PM4/19/12
to adt...@googlegroups.com
On Thu, Apr 19, 2012 at 6:38 AM, raj <morp...@gmail.com> wrote:
Thanks for the advice - found the difference in tools\proguard\proguard-android.txt where optimization is turned off by default.
Will use if (BuildConfig.DEBUG) for Logging.


Xav can confirm or deny, but I believe if you use "ant debug" or "ant release" there's currently an issue where the DEBUG flag isn't properly regenerated. A trivial workaround is to delete the bin folder before "ant release". Xav has a pending fix for the next version.

R/

Xavier Ducrohet

unread,
Apr 19, 2012, 4:50:53 PM4/19/12
to adt...@googlegroups.com
The issue was on Eclipse only and was fixed in 18.0.

Are there other reports of this problem? It's working in my tests.

2012/4/19 Raphaël Moll <ra...@android.com>:

--
Xavier Ducrohet
Android SDK Tech Lead
Google Inc.
http://developer.android.com | http://tools.android.com

Please do not send me questions directly. Thanks!

Raphaël Moll

unread,
Apr 19, 2012, 4:54:42 PM4/19/12
to adt...@googlegroups.com
On Thu, Apr 19, 2012 at 1:50 PM, Xavier Ducrohet <x...@android.com> wrote:
The issue was on Eclipse only and was fixed in 18.0.

Are there other reports of this problem? It's working in my tests.


Ah cool. I'll start using it again then.

R/

Mateo Ortega

unread,
Apr 19, 2012, 6:51:23 PM4/19/12
to adt...@googlegroups.com
Thanks, the BuildConfig.DEBUG route did the trick.

Mateo

Reply all
Reply to author
Forward
0 new messages