Android & Proguard - how to obfuscate, but not optimize any code?

I want to use Proguard to obfuscate application code. I do not need optimization, and I do not need Proguard to delete any classes or methods. All I want is obfuscation. The application uses several library projects.

I hit my head against the wall, trying to do it, and it doesn't work the way I want. I see NoSuchMethodExceptions that were added to the application at runtime, although I thought I turned off the Proguard options.

What are the magic settings so that Proguard JUST gets confused and doesn't optimize ANY code?

UPDATE I confirmed through the trial version and the error that this is an obfuscation process (not optimization or compression) that calls NoSuchMethodExceptions.

Proguard.cfg

-dontpreverify -repackageclasses '' -allowaccessmodification -optimizations !code/simplification/arithmetic -keepattributes *Annotation* -dontshrink -keep public class * extends Object -keep class com.myapp.** { *; } -keep public class * extends android.app.Activity -keep public class * extends android.app.Application -keep public class * extends android.app.Service -keep public class * extends android.content.BroadcastReceiver -keep public class * extends android.content.ContentProvider -keep public class com.myapp.activity.Splash -keep public class com.myapp.alarm.AlarmsViewer -keep public class com.myapp.activity.About -keep public class com.myapp.activity.Base -keep public class com.myapp.activity.BaseWithMenu -keep public class com.myapp.alarm.Alarm -keep public class com.myapp.alarm.AlarmFragment -keep public class com.myapp.alarm.AlarmPagerAdapter -keep public class com.myapp.alarm.AlarmStore -keep public class com.myapp.app.App -keep public class com.myapp.preferences.Preferences -keep public class com.myapp.preferences.PreferencesStore -keep public class * extends android.view.View { public <init>(android.content.Context); public <init>(android.content.Context, android.util.AttributeSet); public <init>(android.content.Context, android.util.AttributeSet, int); public void set*(...); } -keepclasseswithmembers class * { public <init>(android.content.Context, android.util.AttributeSet); } -keepclasseswithmembers class * { public <init>(android.content.Context, android.util.AttributeSet, int); } -keepclassmembers class * implements android.os.Parcelable { static android.os.Parcelable$Creator CREATOR; } -keepclassmembers class **.R$* { public static <fields>; } -keep class android.support.v4.app.** { *; } -keep interface android.support.v4.app.** { *; } -keep class com.actionbarsherlock.** { *; } -keep interface com.actionbarsherlock.** { *; } -keepattributes *Annotation* -keep public interface com.android.vending.licensing.ILicensingService -dontwarn android.support.** 
+8
android proguard
source share
1 answer

I had similar problems some time ago and I solved it for me with brute force and luck. My proguard.cfg is similar, but I have lines:

 -dontshrink -optimizations !code/simplification/arithmetic,!field/*,!class/merging/* 

I can't remember where I got the idea for these optimization options, but they seem to work for me.

There is always a catch switch

 -dontoptimize 

(Indicates not to optimize input class files. By default, optimization is enabled, all methods are optimized at the bytecode level.)

which may be more appropriate.

Finally, I have methods that are only mentioned in xml files (click handlers) that should be explicitly saved using

 -keepclassmembers class * extends android.app.Activity { public void myClickHandler(android.view.View ); } 
+6
source share

All Articles