how to write a proguard config for a remote service lib

1.9k Views Asked by At

i will support a sdk to other users.the export jar file is works good for other app. but in fact,i need to proguard this sdk file.i had write a proguard config file.

    -optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*

-injars libs/sdk.jar
-outjars libs/SDK.jar

# we need line numbers in our stack traces otherwise they are pretty useless
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable

-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
-keep class android.support.v4.** { *; }
-keep interface android.support.v4.** { *; }
-keep interface org.apache.** { *; }

-keepclasseswithmembernames class com.ctv.android.sdk.** {*;}

-keep class **.R$* { *; }

-keepclassmembers class **.R$* {
public static <fields>;
}

-dontwarn org.apache.**
-dontwarn android.support.v4.**

-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 *;
}
-keep public class * extends android.os.IInterface

-keepattributes Signature
-keepattributes *Annotation*

com.ctv.android.sdk.P2PService: is a remote service com.ctv.android.sdk.IP2PService: is the interface by aidl

but, if i use this for another project in eclipse.it shows Stub cannot be resolved or is not a field..why? please help me~~ASAP..Thanks

ok.i solved this. two important issues:

1.

-renamesourcefileattribute SourceFile
-keepattributes Exceptions,InnerClasses,Signature,SourceFile,LineNumberTable,*Annotation*

InnerClasses,it is very important

2.

-keep class com.ctv.android.sdk.IP2PService$** {
    public <fields>;
    public <methods>;
}

-keep class com.ctv.android.sdk.IP2PService$Stub.** {
    public <fields>;
    public <methods>;
}

-keep interface com.ctv.android.sdk.IP2PService$** {*;}

that is all.

0

There are 0 best solutions below