Proguard Rule 사용방법

2022. 7. 1. 00:02Android/Proguard

-dontwarn 패키지명.** : 지정해서 경고 무시

-keep class 패키지명.** : 난독화가 필요하지 않은 경우

-ignorewarnings : 경고 무시

-dontoptimize : 최적화 하지 않기

-dontshrink : 사용하지 않는 메소드 유지

-keepclassmembers : 특정 클래스 멤버 원상태 유지

-keepattributes : 내부 클래스 원상태 유지 적용

-keep class org.xmlpull.v1.** { *; }

-dontwarn org.ejml.**
-dontwarn org.xmlpull.**
-dontwarn io.reactivex.**
-dontwarn com.squareup.okhttp.**
-dontwarn com.thoughtworks.xstream.**
-dontwarn boofcv.**
-dontwarn java.awt.**

자주 사용하는 라이브러리 Proguard Rlue

 

1. Retrofit2

# Platform calls Class.forName on types which do not exist on Android to determine platform.
-dontnote retrofit2.Platform
# Platform used when running on Java 8 VMs. Will not be used at runtime.
-dontwarn retrofit2.Platform$Java8
# Retain generic type information for use by reflection by converters and adapters.
-keepattributes Signature
# Retain declared checked exceptions for use by a Proxy instance.
-keepattributes Exceptions

2. Glide

-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** {
  **[] $VALUES;
  public *;
}

# for DexGuard only
-keepresourcexmlelements manifest/application/meta-data@value=GlideModule

 

3.Picasso

-dontwarn com.squareup.okhttp.**

 

참고 사이트

https://www.guardsquare.com/manual/configuration/usage

 

ProGuard Manual: Usage | Guardsquare

ProGuard documentation about usage, configuration and options.

www.guardsquare.com