4

내 애플 리케이션에서 안드로이드 지원 라이브러리 v4 및 v7을 사용합니다. 지원 라이브러리에서 일부 위젯 만 사용하고 있습니다 (전부는 아님). 그러나 최종 릴리스 API에는 18K 기능이 지원 라이브러리에서 포함됩니다. (스크린 샷 첨부) 어떻게 줄일 수 있습니까? 다음안드로이드 지원 라이브러리 (v4 및 v7)에 대한 Proguard 규칙

enter image description here

내 난독의 설정입니다.

-optimizationpasses 3 

-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.preference.Preference 
-keep public class com.android.vending.billing.IInAppBillingService 
-keepattributes SourceFile,LineNumberTable 
-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); 
} 
-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); 
} 
-keep public class * extends android.app.Activity 
-keep public class * extends android.support.v7.app.AppCompatActivity 
-keep public class * extends android.support.v4.app.Fragment 
-keep public class * extends android.app.Application 
-keep public class * extends android.app.Service 
-keep public class * extends android.app.IntentService 




-dontwarn com.google.appengine.api.urlfetch.** 
-dontwarn rx.** 
-dontwarn retrofit.** 
-keepattributes Signature 
-keepattributes *Annotation* 
-keep class com.squareup.okhttp.** { *; } 
-keep interface com.squareup.okhttp.** { *; } 
-keep class retrofit.** { *; } 
-keepclasseswithmembers class * { 
    @retrofit.http.* <methods>; 
} 

-keep class com.google.** { *; } 
#-keep class org.apache.** { *; } 
#-keep class android.support.** { *; } 
-keep class com.makeramen.** { *; } 
-dontwarn android.net.http.AndroidHttpClient 
-dontwarn com.google.android.gms.** 



# Suppress warnings if you are NOT using IAP: 
-dontwarn com.google.** 
#-dontwarn org.apache.** 
-dontwarn com.makeramen.** 
-dontwarn android.support.** 


-keepattributes Signature 

# For using GSON @Expose annotation 
-keepattributes *Annotation* 

# Gson specific classes 
-keep class sun.misc.Unsafe { *; } 

## -------------- Google play services ------------------ 
-keep class * extends java.util.ListResourceBundle { 
    protected Object[][] getContents(); 
} 

-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable { 
    public static final *** NULL; 
} 

-keepnames @com.google.android.gms.common.annotation.KeepName class * 
-keepclassmembernames class * { 
    @com.google.android.gms.common.annotation.KeepName *; 
} 

-keepnames class * implements android.os.Parcelable { 
    public static final ** CREATOR; 
} 


## --------------- For native methods --------------------- 
-keepclasseswithmembernames class * { 
    native <methods>; 
} 

# ------------- To maintain custom components names that are used on layouts XML --------------- 
-keepclassmembers public class * extends android.view.View { 
    void set*(***); 
    *** get*(); 
} 


## ---------- keep generic information --------------- 
-keepattributes Signature,*Annotation*,EnclosingMethod 
-keep class sun.misc.Unsafe { *; } 


## -------------- keep custom components -------------------- 
-keep public class * extends android.view.View { 
    public <init>(android.content.Context, android.util.AttributeSet); 
} 

-keep public class * extends android.view.View { 
    public <init>(android.content.Context, android.util.AttributeSet, int); 
} 


## ------------ We want to keep methods in Activity that could be used in the XML attribute onClick ------------- 
-keepclassmembers class * extends android.app.Activity { 
    public void *(android.view.View); 
} 



## ---------- For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations ------------- 
-keepclassmembers enum * { 
    public static **[] values(); 
    public static ** valueOf(java.lang.String); 
} 


##------------ To keep parcelable classes (to serialize - deserialize objects to sent through Intents) ------------- 
-keep class * implements android.os.Parcelable { 
    public static final android.os.Parcelable$Creator *; 
} 



## ------------ Keep the R.java file --------------- 
-keepclassmembers class **.R$* { 
    public static <fields>; 
} 



##---------------Begin: proguard configuration for Bean class ---------- 
#-keep public class com.nektapp.datamodels.**{ *; } 
#-keep public class com.nektapp.matcher.model.**{ *;} 

##---------- Keep external jars from libs folder ----------------- 


-libraryjars libs 


##-libraryjars libs/universal-image-loader-1.9.3.jar 
##-libraryjars libs/dropbox-sync-sdk-android.jar 
##-libraryjars libs/gson-2.3.1.jar 
##-libraryjars libs/HockeySDK-3.0.2.jar 
##-libraryjars libs/jackson-core-asl-1.9.7.jar 
##-libraryjars libs/jackson-mapper-asl-1.9.7.jar 
##-libraryjars libs/logback-android-1.0.10-2.jar 
##-libraryjars libs/slf4j-api-1.7.5.jar 


##-dontwarn org.codehaus.jackson.** 
##-keep class org.codehaus.jackson.** { *; } 

-dontwarn ch.qos.logback.** 
-keep class ch.qos.logback.** { *; } 

-dontwarn org.slf4j.** 
-keep class org.slf4j.** { *; } 

# Explicitly preserve all serialization members. The Serializable interface 
# is only a marker interface, so it wouldn't save them. 
-keepclassmembers class * implements java.io.Serializable { 
    static final long serialVersionUID; 
    private static final java.io.ObjectStreamField[] serialPersistentFields; 
    private void writeObject(java.io.ObjectOutputStream); 
    private void readObject(java.io.ObjectInputStream); 
    java.lang.Object writeReplace(); 
    java.lang.Object readResolve(); 
    public void set*(***); 
    public *** get*(); 
    <fields>; 
} 

# Amazon AWS S3 ---------------------- 
# Class names are needed in reflection 
-keepnames class com.amazonaws.** 
# Request handlers defined in request.handlers 
-keep class com.amazonaws.services.**.*Handler 
# The following are referenced but aren't required to run 
-dontwarn com.fasterxml.jackson.** 
#-dontwarn org.apache.commons.logging.** 
# Android 6.0 release removes support for the Apache HTTP client 
#-dontwarn org.apache.http.** 
# The SDK has several references of Apache HTTP client 
-dontwarn com.amazonaws.http.** 
-dontwarn com.amazonaws.metrics.** 
# Amazon AWS S3 ---------------------- 

# Support design 
-dontwarn android.support.design.** 
-keep class android.support.design.** { *; } 
-keep interface android.support.design.** { *; } 
-keep public class android.support.design.R$* { *; } 

# App compat 
-keep public class android.support.v7.widget.** { *; } 
-keep public class android.support.v7.app.** { *; } 
-keep public class android.support.v7.internal.widget.** { *; } 
-keep public class android.support.v7.internal.view.menu.** { *; } 

-keep public class * extends android.support.v4.view.ActionProvider { 
    public <init>(android.content.Context); 
} 
-keep class android.support.v7.widget.RoundRectDrawable { *; } 

# picasso 
-dontwarn com.squareup.okhttp.** 

답변

3

마지막으로 나는 프로 가드 구성으로 만든 문제점을 발견했습니다. Proguard처럼 자동으로이 규칙을 앱에 추가합니다. 그래서 우리는 안드로이드/구글 패키지에 특정한 것을 추가 할 필요가 없다. 다음 줄을 제외하고는 다른 모든 것을 제거했습니다.

-optimizationpasses 5 
-keepattributes SourceFile,LineNumberTable 

모든 제 3 자 jar에 대해 규칙을 추가해야합니다. 제 3 자 라이브러리가 Gradle에서 제공되는 경우 가끔씩 Proguard 규칙이 붙어 있습니다.