Android不混淆第三方jar包

#在proguard.cfg中加入不混淆的jar包和keep不混淆的class:

-libraryjarslibs/HcPaysdk.jar

-keepclasscom.hc.pay.**{*;}

【参考示例】:

在project.properties里加上proguard.config=proguard.cfg

proguard.cfg配置如下:

-optimizationpasses5

-dontusemixedcaseclassnames

-dontskipnonpubliclibraryclasses

-dontpreverify

-verbose

-optimizations!code/simplification/arithmetic,!field/*,!class/merging/*

#忽略警告也可以用-ignorewarnings

-dontwarn

#声明第三方jar包,不用管第三方jar包中的.so文件(如果有)

-libraryjarslibs/baidumapapi.jar

-libraryjarslibs/tencent_openapi.jar

-libraryjarslibs/httpmime-4.1.3.jar

-libraryjarslibs/weibo.sdk.android.sso.jar

-libraryjarslibs/android-support-v4.jar

-keeppublicclass*extendsandroid.app.Activity

-keeppublicclass*extendsandroid.app.Application

-keeppublicclass*extendsandroid.app.Service

-keeppublicclass*extendsandroid.content.BroadcastReceiver

-keeppublicclass*extendsandroid.content.ContentProvider

-keeppublicclass*extendsandroid.app.backup.BackupAgentHelper

-keeppublicclass*extendsandroid.preference.Preference

-keeppublicclasscom.android.vending.licensing.ILicensingService

-keepclasseswithmembernamesclass*{

native<methods>;

}

-keepclasseswithmembersclass*{

public<init>(android.content.Context,android.util.AttributeSet);

}

-keepclasseswithmembersclass*{

public<init>(android.content.Context,android.util.AttributeSet,int);

}

-keepclassmembersclass*extendsandroid.app.Activity{

publicvoid*(android.view.View);

}

-keepclassmembersenum*{

publicstatic**[]values();

publicstatic**valueOf(java.lang.String);

}

-keepclass*implementsandroid.os.Parcelable{

publicstaticfinalandroid.os.Parcelable$Creator*;

}

#不混淆第三方jar包中的类

-keepclasscom.baidu.mapapi.**{*;}

-keepclasscom.tencent.tauth.**{*;}

-keepclassorg.apache.http.entity.mime.**{*;}

-keepclassandroid.support.v4.**{*;}

-keepclassandroid.net.http.**{*;}

-keepclasscom.weibo.sdk.android.**{*;}

-keepclasscom.sina.sso.**{*;}

说明一下,第三方jar包中如果有.so文件,不用去理会,引入的第三方jar文件不要混淆,否则可能会报异常

相关推荐