首页 > 程序开发 > 移动开发 > 其他 > 正文
使用ProGround混淆工具混淆jar包
2017-07-17 09:46:54       个评论    来源:jiumeng01的博客  
收藏    我要投稿

使用ProGround混淆工具混淆jar包

首先打开ProGuard工具,打开路径在E:\sdk\tools\proguard\bin。点击proguardgui.bat

ProGuard的基本使用

\
\
\

配置混淆文件

以下为sdk默认的混淆配置文件,路径/Users/jiumeng/Documents/AndroidWorkSpace/studio_sdk/tools/proguard/proguard-android.text

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

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

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

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

# 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.**

# Understand the @Keep support annotation.
-keep class android.support.annotation.Keep

-keep @android.support.annotation.Keep class * {*;}

-keepclasseswithmembers class * {
    @android.support.annotation.Keep ;
}

-keepclasseswithmembers class * {
    @android.support.annotation.Keep ;
}

-keepclasseswithmembers class * {
    @android.support.annotation.Keep (...);
}

使用ProGuard工具混淆时,copy一份默认的混淆文件,然后在文件末尾添加自己的混淆规则
例如:

#imageloader(保持ImageLoader不被混淆)
-keep class com.ssp.imageloader.** { *; }   

#Init(保持初始化的接口不被混淆)
-keep class com.kok.ssp.adpter.Init
{
    public *;
}

混淆规则相关的blog:http://blog.csdn.net/catoop/article/details/47208833

点击复制链接 与好友分享!回本站首页
上一篇:Gosn对几种情况json数据解析
下一篇:集合List(E)转换成对应元素类型的数组E[]
相关文章
图文推荐
文章
推荐
点击排行

关于我们 | 联系我们 | 广告服务 | 投资合作 | 版权申明 | 在线帮助 | 网站地图 | 作品发布 | Vip技术培训
版权所有: 红黑联盟--致力于做实用的IT技术学习网站