I want to use Proguard to obfuscate an app's code. I don't need optimisations, and I don't need Proguard to strip any classes or methods out. All I want is obfuscation. The app uses several library projects.
I've been banging my head against the wall trying to make it happen and it's not working the way I want. I am seeing NoSuchMethodExceptions thrown in the app when executed, even though I thought I had turned off Proguard's shrinking options.
What are the magic settings to have Proguard JUST obfuscate, and not optimise away ANY code?
UPDATE. I've confirmed through trial and error that it is the obfuscation process (not the optimisation or shrinking) that is causing the 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.**
Apple and Google both have fantastic app stores. But Android is far superior at organizing apps, letting you put important stuff on the home screens and hide less useful apps in the app drawer. Also, Android's widgets are much more useful than Apple's.
Android Inc., was bought by the American search engine company Google Inc., in 2005. At Google, the Android team decided to base their project on Linux, an open source operating system for personal computers.
Samsung is just one manufacturer that uses Android. Others include Sony, Motorola, LG, OnePlus, and Huawei. But while all of these manufacturers use Android on their phones, that doesn't mean the experience is the same on all of them. This goes back to the open-source nature of Android.
Definition of android : a mobile robot usually with a human form sci-fi androids.
I had similar problems a while back and solved it for me by brute force and luck. My proguard.cfg is similar but I have the lines:
-dontshrink
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
I can't remember from where I got the idea for these optimization options, but they seem to work for me.
There is always the catch all switch
-dontoptimize
(Specifies not to optimize the input class files. By default, optimization is enabled; all methods are optimized at a bytecode level.)
which might be more appropriate.
Finally I have methods which are only referenced in xml files (click handlers) which needed to be explicitly kept with
-keepclassmembers class * extends android.app.Activity {
public void myClickHandler(android.view.View );
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With