How to keep external libraries in proguard android
You need to use -keep
to keep the class from any packages, something like:
-keep class io.crossbar.** { *; }
-dontwarn
will only ignore the warnings. With, -keep
you can keep any classes, class fields, and methods.
For more detailed usage check: ProGuard manual
Also, there is a feature request on GitHub for this repo to support ProGuard, here.
Ignore external libraries with Android proguard
This proguard configuration help me: Proguard obfuscation is breaking simplexml
# The following line may be different
-libraryjars <java.home>/lib/rt.jar(java/**,javax/**)
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
# (3)Not remove unused code
-dontshrink
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-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.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService
# (2)Simple XML
-keep public class org.simpleframework.**{ *; }
-keep class org.simpleframework.xml.**{ *; }
-keep class org.simpleframework.xml.core.**{ *; }
-keep class org.simpleframework.xml.util.**{ *; }
# (1)Annotations and signatures
-keepattributes *Annotation*
-keepattributes Signature
-keepclasseswithmembernames class * {
native <methods>;
}
-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.app.Activity {
public void *(android.view.View);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
How can I exclude external .jar from obfuscation by Proguard (Android project)?
If you don't want to edit the Ant script, you can add -keep options to proguard.cfg for the classes in those external jars. For instance:
-keep class othercode.** { *; }
Or with a regular expression containing a negator:
-keep class !mycode.** { *; }
The standard Ant script will still merge all referenced jars in the single output jar though.
How to exempt a library module from pro-guard in android gradle
The solution is to look up for the methods and classess that needs to be exempted and add them to the proguard rules as follows ( Here I needed to keep the files in classes com.mm.** and com.company.** where ** acts as wild char
-keep class com.mm.** {*;}
-keep class com.company.** {*;}
-keepclassmembers class com.mm.** {*;}
-keepclassmembers class com.company.** {*;}
Related Topics
What Is the Default Font Family in Android
Eclipse, Android, Scala Made Easy But Still Does Not Work
Facebook Authentication Without Login Button
Can You Launch the Native Camera App from an HTML 5 Web App
App Not Setup: This App Is Still in Development Mode
Official "Boost Library" Support for Android and iOS
Display Huge Images in Android
Android Navigation Architecture Component - Get Current Visible Fragment
How to Merge Call Programmatically While Other Call Is Running (Conference Call)
Broadcast Receiver Won't Receive Camera Event
How to Get Add to Home Screen Pop Up on Site Open in Mobile Browser
Android and Setting Alpha for (Image) View Alpha
Build Errors After Android Studio 3.2.1 Upgrade
Remove Padding Around Action Bar Left Icon on Android 4.0+
Alarmmanager Android Every Day
Travis Ci Failed Because Cannot Accept License Constrain Layout