I noticed that with newly created projects, a new approach to proguard has appeared, which should use a pre-built script:
$ {sdk.dir} /tools/proguard/proguard-android.txt
This is without optimization and comes with a comment:
Optimization is disabled by default. Dex does not like running code through ProGuard to optimize and pre-check steps (and performs some of these optimizations separately).
It seems that following this advice means that assumenosideeffects not valid. For example, these common tasks:
#Remove logging -assumenosideeffects class android.util.Log { public static boolean isLoggable(java.lang.String, int); public static int v(...); public static int i(...); public static int w(...); public static int d(...); public static int e(...); } #Remove asserts -assumenosideeffects class junit.framework.Assert { public static *** assert*(...); }
Proof that it does not work:
if (release) { Assert.assertTrue("Proguard config error, Asserts have been left in", false); }
Is there a safe middle ground where I can apply optimization to trim debugging, as defined in assumenosideeffects , but without risking the associated problems with optimizing Dex and proguard?
source share