Reputation: 179
I want to obfuscate a few classes in my Android Studio project using proguard. These are some fragments in com.myproject.fragments folder. All of these classes are extending Android's Fragment class. It seems that as of now my proguard rules are excluding these classes from obfuscation. Please tell me how I can edit my proguard rules files to make this obfuscation happen.
-dontpreverify
-repackageclasses ''
-allowaccessmodification
-optimizations !code/simplification/arithmetic
-keepattributes *Annotation*
-keepattributes Signature
-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 * extends android.content.Context
-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 * extends android.content.Context {
public void *(android.view.View);
public void *(android.view.MenuItem);
}
-keepclassmembers class * implements android.os.Parcelable {
static ** CREATOR;
}
-keepclassmembers class **.R$* {
public static <fields>;
}
-keepclassmembers class * {
@android.webkit.JavascriptInterface <methods>;
}
# Preserve the special static methods that are required in all enumeration classes.
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
public *;
}
-keep public enum com.sync.model$** {
**[] $VALUES;
public *;
}
# Application classes that will be serialized/deserialized over Gson
-keep class com.myproject.models.** { *; }
-keep class com.myproject.httputils.** { *; }
-keep class com.facebook.** {
*;
}
-keep class com.androidplot.** { *; }
-keepclassmembers class * extends com.actionbarsherlock.ActionBarSherlock {
<init>(android.app.Activity, int);
}
# Gson specific classes
#-keep class sun.misc.Unsafe { *; }
-keep class com.google.gson.stream.** { *; }
Upvotes: 1
Views: 731
Reputation:
You can excluding particular class & Package in Proguard file...
For excluding particular class
-keep class com.demo.fragment.myfragment { *; }
For excluding whole package classes
-keep class com.demo.fragment. { *; }**
Upvotes: 1
Reputation: 10309
It seems you're using the proguard file template provided here https://code.google.com/p/google-gson/source/browse/trunk/examples/android-proguard-example/proguard.cfg
It has not been updated since 2011
Also check this ProGuard for Android and GSON
Upvotes: 0