代码混淆

6人阅读 评论(0) 收藏 举报
分类:

1. progurd-reles.pro

#---------------------------基本配置-------------------------------
-optimizationpasses 5 # 指定代码的压缩级别
-dontusemixedcaseclassnames # 是否使用大小写混合
-dontpreverify # 混淆时是否做预校验
-verbose # 混淆时是否记录日志
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/* # 混淆时所采用的算法
-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 # 保持哪些类不被混淆
#这句非常重要,主要是滤掉 com.demo.demo.bean包下的所有.class文件不进行混淆编译,com.demo.demo是你的包名
-keep class 包名.bean.** {*;}
-keepclasseswithmembernames class * { # 保持 native 方法不被混淆
   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 * { # 保持枚举 enum 类不被混淆
   public static **[] values();
   public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {#保持Parcelable不被混淆
   public static final android.os.Parcelable$Creator *;
}
# Explicitly preserve all serialization members. The Serializable interface
# is only a marker interface, so it wouldn't save them.
-keep public class * implements java.io.Serializable {*;}
-keepclassmembers class * implements java.io.Serializable {
   static final long serialVersionUID;
   private static final java.io.ObjectStreamField[]   serialPersistentFields;
   private void writeObject(java.io.ObjectOutputStream);
   private void readObject(java.io.ObjectInputStream);
   java.lang.Object writeReplace();
   java.lang.Object readResolve();
}
-keepclassmembers class * {
   public <init> (org.json.JSONObject);
}
#com.demo.demo是你的包名
-keep public class 包名.R$*{
   public static final int *;
}
#
-dontwarn org.apache.http.**
# 不做预校验
-dontpreverify
### 忽略警告
-ignorewarning
#如果引用了v4或者v7包
-dontwarn android.support.**
-keepattributes EnclosingMethod
 #如果有其它包有warning,在报出warning的包加入下面类似的-dontwarn 报名
#-dontwarn com.fengmap.*.*
## 注解支持
-keepclassmembers class *{
   void *(android.view.View);}

#---------------------------------3.与js互相调用的类------------------------
-keep class 包名.ui.** { *; }

#---------------------------------webview------------------------------------
-keepclassmembers class fqcn.of.javascript.interface.for.Webview {
      public *;
  }
-keepclassmembers class * extends android.webkit.WebViewClient {
       public void *(android.webkit.WebView, java.lang.String, android.graphics.Bitmap);
       public boolean *(android.webkit.WebView, java.lang.String);
   }
-keepclassmembers class * extends android.webkit.WebViewClient {
       public void *(android.webkit.WebView, jav.lang.String);
   }

#-------------------------------------第三方相关------------------------------
#gson..................
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature
# Gson specific classes
-keep class sun.misc.Unsafe { *; }
-keep class com.google.gson.stream.** { *; }
# Application classes that will be serialized/deserialized over Gson
-keep class com.google.gson.examples.android.model.** { *; }
-keep class com.google.gson.** { *;}

# retrolambda
-dontwarn java.lang.invoke.*

#Glide
-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public class * extends com.bumptech.glide.module.AppGlideModule
-keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** {
  **[] $VALUES;
  public *;
}

#-keep class com.taobao.** { *;}
#
#-dontwarn com.alibaba.**
#-keep class com.alibaba.** { *;}
#友盟推送
-dontwarn com.taobao.**
-dontwarn anet.channel.**
-dontwarn anetwork.channel.**
-dontwarn org.android.**
-dontwarn org.apache.thrift.**
-dontwarn com.xiaomi.**
-dontwarn com.huawei.**
-dontwarn com.meizu.**

-keepattributes *Annotation*

-keep class com.taobao.** {*;}
-keep class org.android.** {*;}
-keep class anet.channel.** {*;}
-keep class com.umeng.** {*;}
-keep class com.xiaomi.** {*;}
-keep class com.huawei.** {*;}
-keep class com.meizu.** {*;}
-keep class org.apache.thrift.** {*;}

-keep class com.alibaba.sdk.android.**{*;}
-keep class com.ut.**{*;}
-keep class com.ta.**{*;}

-keep public class **.R$*{
   public static final int *;
}

#(可选)避免Log打印输出
-assumenosideeffects class android.util.Log {
   public static *** v(...);
   public static *** d(...);
   public static *** i(...);
   public static *** w(...);
 }

#友盟分享
-dontshrink
-dontoptimize
-dontwarn com.google.android.maps.**
-dontwarn android.webkit.WebView
-dontwarn com.umeng.**
-dontwarn com.tencent.weibo.sdk.**
-dontwarn com.facebook.**
-keep public class javax.**
-keep public class android.webkit.**
-dontwarn android.support.v4.**
-keep enum com.facebook.**
-keepattributes Exceptions,InnerClasses,Signature
-keepattributes *Annotation*
-keepattributes SourceFile,LineNumberTable

-keep public interface com.facebook.**
-keep public interface com.tencent.**
-keep public interface com.umeng.socialize.**
-keep public interface com.umeng.socialize.sensor.**
-keep public interface com.umeng.scrshot.**

-keep public class com.umeng.socialize.* {*;}


-keep class com.facebook.**
-keep class com.facebook.** { *; }
-keep class com.umeng.scrshot.**
-keep public class com.tencent.** {*;}
-keep class com.umeng.socialize.sensor.**
-keep class com.umeng.socialize.handler.**
-keep class com.umeng.socialize.handler.*
-keep class com.umeng.weixin.handler.**
-keep class com.umeng.weixin.handler.*
-keep class com.umeng.qq.handler.**
-keep class com.umeng.qq.handler.*
-keep class UMMoreHandler{*;}
-keep class com.tencent.mm.sdk.modelmsg.WXMediaMessage {*;}
-keep class com.tencent.mm.sdk.modelmsg.** implements com.tencent.mm.sdk.modelmsg.WXMediaMessage$IMediaObject {*;}
-keep class im.yixin.sdk.api.YXMessage {*;}
-keep class im.yixin.sdk.api.** implements im.yixin.sdk.api.YXMessage$YXMessageData{*;}
-keep class com.tencent.mm.sdk.** {
   *;
}
-keep class com.tencent.mm.opensdk.** {
   *;
}
-keep class com.tencent.wxop.** {
   *;
}
-keep class com.tencent.mm.sdk.** {
   *;
}
-dontwarn twitter4j.**
-keep class twitter4j.** { *; }

-keep class com.tencent.** {*;}
-dontwarn com.tencent.**
-keep class com.kakao.** {*;}
-dontwarn com.kakao.**
-keep public class com.umeng.com.umeng.soexample.R$*{
    public static final int *;
}
-keep public class com.linkedin.android.mobilesdk.R$*{
    public static final int *;
}
-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

-keep class com.tencent.open.TDialog$*
-keep class com.tencent.open.TDialog$* {*;}
-keep class com.tencent.open.PKDialog
-keep class com.tencent.open.PKDialog {*;}
-keep class com.tencent.open.PKDialog$*
-keep class com.tencent.open.PKDialog$* {*;}
-keep class com.umeng.socialize.impl.ImageImpl {*;}
-keep class com.sina.** {*;}
-dontwarn com.sina.**
-keep class  com.alipay.share.sdk.** {
   *;
}

-keepnames class * implements android.os.Parcelable {
    public static final ** CREATOR;
}

-keep class com.linkedin.** { *; }
-keep class com.android.dingtalk.share.ddsharemodule.** { *; }
-keepattributes Signature

#Picasso
-dontwarn com.squareup.okhttp.**

-dontwarn java.nio.**

-dontwarn com.com.palmnewsclient.http.rx.**
-keep class com.com.palmnewsclient.http.rx.** { *;}

#com.tbruyelle.rxpermissions
-dontwarn com.tbruyelle.rxpermissions.**
-keep class com.tbruyelle.rxpermissions.** {*;}

#EventBus
-keepattributes *Annotation*
-keepclassmembers class ** {
    @de.greenrobot.event.Subscribe <methods>;
}
-keep enum de.greenrobot.event.ThreadMode { *; }
-keepclassmembers class * extends de.greenrobot.event.util.ThrowableFailureEvent {
    <init>(Java.lang.Throwable);
}
-keepclassmembers class ** {
    public void onEvent*(**);
}

#PullToRefreshLibrary下拉刷新框架不混淆
-keep class com.handmark.pulltorefresh.library.** { *; }
-dontwarn com.handmark.pulltorefresh.library.**
# OkHttp
-keepattributes Signature
-keepattributes *Annotation*
-keep class okhttp.** { *; }
-keep interface okhttp.** { *; }
-dontwarn okhttp.**
#design
-dontwarn android.support.design.**
-keep class android.support.design.** { *; }
-keep interface android.support.design.** { *; }
-keep public class android.support.design.R$* { *; }
# Glide
# https://github.com/bumptech/glide
-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** {
    **[] $VALUES;
    public *;
}
# volley
-dontwarn com.android.volley.jar.**
-keep class com.android.volley.**{*;}

2.build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion '25.0.0'

    defaultConfig {
        applicationId "你的包名com.test"
        minSdkVersion 23
        targetSdkVersion 22
        versionCode 13769
        versionName "2.0.8"
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        ndk{abiFilters "armeabi", "armeabi-v7a", "x86", "mips"}
    }
    lintOptions {
        checkReleaseBuilds false
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false
    }
    signingConfigs {
        debug {
            storeFile file('D:/signFile/秘钥名称') //秘钥文件所在目录
                storePassword "你的密码"
                keyAlias "秘钥名称"
                keyPassword "你的密码"
        }

        release {
        }
    }
    buildTypes {
        release {
            signingConfig signingConfigs.release
            minifyEnabled true
            zipAlignEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            signingConfig signingConfigs.debug

        }

    }
    }

dependencies {
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.google.code.gson:gson:2.2.4'
    compile 'com.squareup.okhttp:okhttp:2.5.0'
    compile 'com.squareup.okhttp:okhttp-urlconnection:2.5.0'
    compile 'com.mcxiaoke.volley:library:1.0.16'
    compile 'com.google.android.gms:play-services-appindexing:8.4.0'
    compile 'com.android.support:support-v4:23.0.0'
    compile 'com.android.support:design:23.2.0'
    compile 'de.greenrobot:eventbus:3.0.0-beta1'
    compile files('src/main/libs/universal-image-loader-1.9.5.jar')
    compile files('src/main/libs/pgyer_sdk_2.4.5.jar')
    compile files('src/main/libs/tecentwebview.jar')
    compile files('src/main/libs/glide-3.7.0.jar')
    compile project(':pullToRefreshLibrary')
    compile project(':wheel')
    //推送

    //分享
    compile files('src/main/libs/SocialSDK_QQ_Simplify.jar')
    compile files('src/main/libs/SocialSDK_WeChat_Simplify.jar')
    compile files('src/main/libs/umeng_social_api.jar')
    compile files('src/main/libs/umeng_social_net.jar')
    compile files('src/main/libs/umeng_social_tool.jar')
    compile 'me.imid.swipebacklayout.lib:library:1.0.0'
    compile project(':PushSDK')
    compile 'com.github.chrisbanes.photoview:library:+'
    //解析Html标签
    compile 'org.jsoup:jsoup:1.10.3'
}

查看评论

Java之优雅编程之道

《Java之优雅编程之道》主要是针对有一定基础的Java学员。本课程主要是围绕着如何编写整洁的Java代码,如何实现Java代码重构,以及如何提高Java代码性能而展开的一系列课程。本课程结合自身的真实工作经验,从最常用的注释,名字,集合,数组,方法等等开始讲起,由浅到深,层层深入。通过本课程的学习,可以帮助Java学员编写出整洁,规范,高效的代码。
  • 2017年06月10日 00:34

Allatori java 代码混淆

  • 2017年11月27日 23:47
  • 942KB
  • 下载

JS代码混淆软件(小巧实用)

  • 2011年06月11日 23:29
  • 29KB
  • 下载

DotNETReactor代码混淆器

  • 2010年04月14日 13:58
  • 3.85MB
  • 下载

代码混淆之道(一)

本文原创作者:penguin_wwy, 本文属i春秋的原创奖励计划,未经许可禁止转载! 代码混淆是软件保护技术的一种,而且是最重要却又最难以捉摸的一类(这话不是我说的,是Christian C...
  • wodafa
  • wodafa
  • 2017-04-06 10:14:13
  • 541

C#代码混淆

  • 2017年07月28日 11:14
  • 803KB
  • 下载

各语言的代码混淆工具

C++:Stunnix CXX-Obfus http://www.stunnix.com/prod/cxxo/overview.shtmlJava:Proguard(支持文件过滤,防止反射的代码被混淆...
  • wag2765
  • wag2765
  • 2016-01-25 16:39:01
  • 2200

Objective-C代码混淆

class-dump可以很方便的导出程序头文件,不仅让攻击者了解了程序结构方便逆向,还让着急赶进度时写出的欠完善的程序给同行留下笑柄。 所以,我们迫切的希望混淆自己的代码。 混淆的常规思路 ...
  • y2888886
  • y2888886
  • 2015-12-22 20:06:31
  • 500

【Java代码保护技术】代码混淆

作者:郭孝星 微博:郭孝星的新浪微博 邮箱:allenwells@163.com 博客:http://blog.csdn.net/allenwells Github:https://githu...
  • AllenWells
  • AllenWells
  • 2015-08-11 17:15:56
  • 1039

代码混淆的实现原理与方法

由于java和.net这类高层抽象语言,具有 天生的易反汇编 特性,其编译后的程序包包含了大量的源代码变量、函数名、数据结构等信息 根据其编译后的程序包,可以非常容易的得到 近乎源代码质量 的反汇编代...
  • fulinwsuafcie
  • fulinwsuafcie
  • 2013-09-02 19:52:15
  • 14833
    个人资料
    持之以恒
    等级:
    访问量: 3万+
    积分: 1106
    排名: 4万+
    最新评论