如何为远程服务lib编写proguard配置

时间:2013-12-03 14:05:23

标签: android eclipse class proguard aidl

我将支持sdk给其他用户。导出jar文件适用于其他应用程序。 但事实上,我需要预测这个sdk文件。我已经编写了一个proguard配置文件。

    -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:是一个远程服务 com.ctv.android.sdk.IP2PService:是aidl的接口

但是, 如果我在eclipse中使用这个用于另一个项目。它显示Stub无法解析或者不是一个字段..为什么? 请帮助我~~尽快...谢谢

ok.i解决了这个问题。 两个重要问题:

1

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

InnerClasses,非常重要

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$** {*;}

就是这样。

0 个答案:

没有答案