关于混淆编译

一直觉得混淆编译用处不大.


今天突然发现混淆编译还有减小包大小的功能;


android ADT自带混淆编译,你需要:

1.adt升级到最新,这样避免部分时候混淆出错的问题;

2.project.properties中加入proguard.config = proguard-android.txt,其中proguard-android.txt是你的配置文件,再根目录下.

3.配置文件:

   

# This is a configuration file for ProGuard.
# http://proguard.sourceforge.net/index.html#manual/usage.html

-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose

# Optimization is turned off by default. Dex does not like code run
# through the ProGuard optimize and preverify steps (and performs some
# of these optimizations on its own).
-dontoptimize
-dontpreverify
# Note that if you want to enable optimization, you cannot just
# include optimization flags in your own project configuration file;
# instead you will need to point to the
# "proguard-android-optimize.txt" file instead of this one from your
# project.properties file.

-keepattributes *Annotation*
-keep public class com.google.vending.licensing.ILicensingService
-keep public class com.android.vending.licensing.ILicensingService

# For native methods, see http://proguard.sourceforge.net/manual/examples.html#native
-keepclasseswithmembernames class * {
    native <methods>;
}

# keep setters in Views so that animations can still work.
# see http://proguard.sourceforge.net/manual/examples.html#beans
-keepclassmembers public class * extends android.view.View {
   void set*(***);
   *** get*();
}

# 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);
}

-keep class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator *;
}

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

# The support library contains references to newer platform versions.
# Don't warn about those in case this app is linking against an older
# platform version.  We know about them, and they are safe.
-dontwarn android.support.**
-keep class android.support.** { *;}

-libraryjars libs/ad_adchina_android_mobile_sdk.jar
-libraryjars libs/ad_adwosdk2.5.1.jar
-libraryjars libs/ad_baidu_api.jar
-libraryjars libs/ad_dianru_android_sdk_V2.1.0.jar
-libraryjars libs/ad_domob_android_sdk.jar
-libraryjars libs/ad_iMochaAndroid.jar
-libraryjars libs/ad_mobisageSDK.jar
-libraryjars libs/ad_mobplate-android-sdk-1.21.jar
-libraryjars libs/ad_qumi_android_1.03.jar
-libraryjars libs/ad_smartmad-sdk-android.jar
-libraryjars libs/ad_Tencent_MobWIN_SDK_2.0.jar
-libraryjars libs/ad_umeng_ad_android_sdk_v1.4.4.jar
-libraryjars libs/ad_youmi-android_v3.05_2011-12-30.jar
-libraryjars libs/chardet.jar
-libraryjars libs/sq_ad_2.10.jar
-libraryjars libs/sq_data_1.3.jar
-libraryjars libs/sq_log_2.0.jar
-libraryjars libs/sq_owswitch_1.3.jar
-libraryjars libs/sq_update_1.6.jar
-libraryjars libs/sq_version_2.1.jar

-dontwarn com.adchina.**
-keep class com.adchina.** { *;}

-dontwarn com.adwo.**
-keep class com.adwo.** { *;}

-dontwarn com.baidu.**
-keep class com.baidu.** { *;}

-dontwarn com.dianru.**
-keep class com.dianru.** { *;}

-dontwarn cn.domob.**
-keep class cn.domob.** { *;}

-dontwarn com.imocha.**
-keep class com.imocha.** { *;}

-dontwarn com.mobisage.**
-keep class com.mobisage.** { *;}

-dontwarn com.suizong.**
-keep class com.suizong.** { *;}

-dontwarn com.qumi.**
-keep class com.qumi.** { *;}

-dontwarn com.madhouse.**
-keep class com.madhouse.** { *;}

-dontwarn com.tencent.**
-keep class com.tencent.** { *;}

-dontwarn net.youmi.**
-keep class net.youmi.** { *;}

-dontwarn com.umengAd.**
-keep class com.umengAd.** { *;}

-dontwarn org.mozilla.intl.**
-keep class org.mozilla.intl.** { *;}

-dontwarn com.sq.sdk.**
-keep class com.sq.sdk.** { *;}

-keepclasseswithmembers class com.shuqi.common.Config{
    public static <fields>;
}

需要注意的是,所有在配置文件中引用的类和类成员都不能混淆,第三方jar包不能混淆,还有反射用到的类和类成员不能混淆.所以调试很需要耐心.




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值