• Android开发代码混淆经验(Eclipse)


    为了防止自己的劳动成果被别人窃取,混淆代码能有效防止被反编译,下面来总结以下混淆代码的步骤:

    2、编辑项目下的proguard-project.txt,添加不需要混淆的规则(model、泛型、反射、第三方jar包),proguard-project.txt文件内容如下:

    # To enable ProGuard in your project, edit project.properties
    # to define the proguard.config property as described in that file.
    #
    # Add project specific ProGuard rules here.
    # By default, the flags in this file are appended to flags specified
    # in ${sdk.dir}/tools/proguard/proguard-android.txt
    # You can edit the include path and order by changing the ProGuard
    # include property in project.properties.
    #
    # For more details, see
    #   http://developer.android.com/guide/developing/tools/proguard.html
    
    # Add any project specific keep options here:
    
    # If your project uses WebView with JS, uncomment the following
    # and specify the fully qualified class name to the JavaScript interface
    # class:
    #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
    #   public *;
    #}
    
    #####################################
    ######### 主程序不能混淆的代码 #########
    #####################################
    ######-dontwarn xxx.model.**
    ######-keep class xxx.model.** { *; }
    
    #####################################
    ########### 不优化泛型和反射 ##########
    #####################################
    -keepattributes Signature
    -keep class * extends java.lang.annotation.Annotation { *; }
    
    #####################################
    ######### 不混淆第三方库或者jar包 #######
    #####################################
    -dontwarn net.sourceforge.jtds.**
    -keep class net.sourceforge.jtds.** { *; }
    
    -dontwarn com.iflytek.speech.**
    -keep class com.iflytek.speech.** { *; }
    
    -dontwarn com.lidroid.xutils.**
    -keep class com.lidroid.xutils.** { *; }
    #####################################

    技巧:第三方jar包包名可以用WinRAR来打开jar文件,获取包路径。例如:jtds-1.2.jar,用WinRAR查看,可以发现包名为:net.sourceforge.jtds,所以只需要添加如下2行代码,即可不混淆该jar文件的相关包和类:

    -dontwarn net.sourceforge.jtds.**
    -keep class net.sourceforge.jtds.** { *; }



    参考文章:
    1、http://blog.csdn.net/lovexjyong/article/details/24652085
    2、http://www.cnblogs.com/qianxudetianxia/p/4948499.html


  • 相关阅读:
    Application.Current的使用
    .NET中资源文件的使用
    PMP模拟试题与解析(七)
    PMP模拟试题与解析(四)
    RMAN命令简介
    数据库备份和恢复概述
    ORA-14402: updating partition key column would cause a partition change
    RMAN概述
    PLS-00642: local collection types not allowed in SQL statements
    SFTP(Secure File Transfer Protocol)安全的文件传输协议的使用
  • 原文地址:https://www.cnblogs.com/tc310/p/4949812.html
Copyright © 2020-2023  润新知