由于最近需要打包上传apk到应用市场。用到了一些开源项目。但发布apk需要混淆,而很多的项目的混淆规则都不太清楚,找起来太费劲了。就想着整个一个文档。
现在把这些的混淆规则分享给大家,也省得大家再去其它地方查找了。
提前说明:有些混淆规则可能未能及时更新,会有误差,若大家发现,欢迎指明。
proguard-square-retrofit2.pro
# Retrofit 2.X
## https://square.github.io/retrofit/ ##
-dontwarn retrofit2.**
-keep class retrofit2.** { *; }
-keepattributes Signature
-keepattributes Exceptions
-keepclasseswithmembers class * {
@retrofit2.http.* <methods>;
}
proguard-square-retrofit.pro
# Retrofit 1.X
-keep class com.squareup.okhttp.** { *; }
-keep class retrofit.** { *; }
-keep interface com.squareup.okhttp.** { *; }
-dontwarn com.squareup.okhttp.**
-dontwarn okio.**
-dontwarn retrofit.**
-dontwarn rx.**
-keepclasseswithmembers class * {
@retrofit.http.* <methods>;
}
# If in your rest service interface you use methods with Callback argument.
-keepattributes Exceptions
# If your rest service methods throw custom exceptions, because you've defined an ErrorHandler.
-keepattributes Signature
# Also you must note that if you are using GSON for conversion from JSON to POJO representation, you must ignore those POJO classes from being obfuscated.
# Here include the POJO's that have you have created for mapping JSON response to POJO for example.
proguard-square-otto.pro
## Square Otto specific rules ##
## https://square.github.io/otto/ ##
-keepattributes *Annotation*
-keepclassmembers class ** {
@com.squareup.otto.Subscribe public *;
@com.squareup.otto.Produce public *;
}
proguard-square-picasso.pro
## Square Picasso specific rules ##
## https://square.github.io/picasso/ ##
-dontwarn com.squareup.okhttp.**
proguard-square-okhttp3.pro