• 简单Android代码混淆(转)


    代码混淆步骤:

    1,project.properties中打开代码混淆功能,加入proguard.config=proguard.cfg

    2,编辑proguard.cfg文件,项目没有自动生成时可手工新建并放到项目根目录,内容如下

    -optimizationpasses 5  
    -dontusemixedcaseclassnames  
    -dontskipnonpubliclibraryclasses  
    -dontpreverify  
    -verbose  
    -optimizations !code/simplification/arithmetic,!field/*,!class/merging/*  
    -ignorewarnings  
    -libraryjars libs/android-support-v4.jar  
      
    -dontwarn android.support.v4.**      
    -keep class android.support.v4.** { *; }    
    -keep interface android.support.v4.app.** { *; }    
    -keep public class * extends android.support.v4.**    
    -keep public class * extends android.app.Fragment  
      
    -libraryjars libs/asmack.jar  
    -libraryjars libs/aws-android-sdk-1.7.1.1-core.jar  
    -libraryjars libs/aws-android-sdk-1.7.1.1-s3.jar  
    -libraryjars libs/LibFrameWidget.jar  
    -libraryjars libs/LibFramework.jar  
    -libraryjars libs/locSDK_4.0.jar  
    -libraryjars libs/umeng_sdk.jar  
    -libraryjars libs/zxing-core.jar  
    -keep public class * extends android.app.Activity  
    -keep public class * extends android.app.Application  
    -keep public class * extends android.app.Service  
    -keep public class * extends android.content.BroadcastReceiver  
    -keep public class * extends android.content.ContentProvider  
    -keep public class com.android.vending.licensing.ILicensingService  
      
    -keepclasseswithmembernames class * {  
        native <methods>;  
    }  
      
    -keepclasseswithmembernames class * {  
        public <init>(android.content.Context, android.util.AttributeSet);  
    }  
      
    -keepclasseswithmembernames class * {  
        public <init>(android.content.Context, android.util.AttributeSet, int);  
    }  
      
    -keepclassmembers enum * {  
        public static **[] values();  
        public static ** valueOf(java.lang.String);  
    }  
      
    -keep class * implements android.os.Parcelable {  
      public static final android.os.Parcelable$Creator *;  
    }
    

      

    应该注意的地方如下:

    1,android-support-v4.jar报错的话,要加上下面的代码

    -ignorewarnings

    -dontwarn android.support.v4.**    
    -keep class android.support.v4.** { *; }  
    -keep interface android.support.v4.app.** { *; }  
    -keep public class * extends android.support.v4.**  
    -keep public class * extends android.app.Fragment

    2,所有Libs下的jar包都要加上引用说明,格式如下(*未对应的jar包名称)

    -libraryjars libs/*.jar

  • 相关阅读:
    ElasticSearch应用之数据埋点——认识埋点
    WebStorm好用的插件推荐
    mysql身份验证问题
    (一) MySql的安装
    (一)Mongodb的下载与安装
    解决Flask中 request.get_json()接收不到传来的json数据
    docker查看日志记录
    微信小程序右上角胶囊的信息
    linux shell 字符串操作(长度,查找,替换)详解
    Win7下的内置FTP组件的设置详解
  • 原文地址:https://www.cnblogs.com/JayK/p/4900408.html
Copyright © 2020-2023  润新知