Android2.3 proguard介绍---代码混淆技术
来源:互联网 发布:长筒运动袜 知乎 编辑:程序博客网 时间:2024/04/30 12:58
http://blog.csdn.net/Zengyangtech/article/details/6127600
由于各种反编译工具的泛滥,作为Android程序员在2.3版本以前只能通过手动添加proguard来实现代码混淆
proguard这个工具是一个java代码混淆的工具
在2.3版本的sdk中 我们可以看到在android-sdk-windows/tools/下面多了一个proguard文件夹
google已经把proguard技术放在了android sdk里面 可以通过正常的编译方式也能实现代码混淆了
可以看见新建一个工程里面有default.properties和proguard.cfg
默认的default.properties代码如下
- # This file is automatically generated by Android Tools.
- # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
- #
- # This file must be checked in Version Control Systems.
- #
- # To customize properties used by the Ant build system use,
- # "build.properties", and override values to adapt the script to your
- # project structure.
- # Project target.
- target=android-9
我们可以看到proguard.cfg已经帮我们写好了优化代码脚本
- -optimizationpasses 5
- -dontusemixedcaseclassnames
- -dontskipnonpubliclibraryclasses
- -dontpreverify
- -verbose
- -optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
- -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 *;
- }
从脚本中可以看到,混淆中保留了继承自Activity、Service、Application、BroadcastReceiver、ContentProvider等基本组件以及com.android.vending.licensing.ILicensingService
并保留了所有的Native变量名及类名,所有类中部分以设定了固定参数格式的构造函数,枚举等等。(详细信息请参考<proguard_path>/examples中的例子及注释。)
接下来 按照google帮助文档里说的
- To enable ProGuard so that it runs as part of an Ant or Eclipse build, set the proguard.config property in the <project_root>/default.properties file. The path can be an absolute path or a path relative to the project's root.
所以我们修改default.properties file
加上一句
proguard.config=proguard.cfg
如下
- # This file is automatically generated by Android Tools.
- # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
- #
- # This file must be checked in Version Control Systems.
- #
- # To customize properties used by the Ant build system use,
- # "build.properties", and override values to adapt the script to your
- # project structure.
- # Project target.
- target=android-9
- proguard.config=proguard.cfg
然后正常的编译签名即可
然后用Android Tools生成一个发布的apk即可
然后用反编译工具查看dex文件
最后导出反编译之后的混淆代码如下图
是不是很轻松加愉快!希望各位程序员都能保护好自己的Android代码!
http://blog.csdn.net/evilcode/article/details/6860182
针对android 选择user版本进行编译的时候,会出现proguard错误,我们需要知道的事情
1.proguard是做什么的,他的作用是将java代码进行混淆的工具
2.因为proguard是混淆工具,所以android的mk文件也对其支持为两种方式:
1.指定不需要混淆的native方法与变量的proguard.flags文件
如:LOCAL_PROGUARD_FLAG_FILES := proguard.flags
2.制定编译的工程,不要使用代码混淆的工具进行代码混淆
如:LOCAL_PROGUARD_ENABLED := disabled
3.不设置,默认使用LOCAL_PROGUARD_ENABLED := full.即将该工程代码全部混淆
- Android2.3 proguard介绍---代码混淆技术
- Android 2.3 代码混淆proguard技术介绍
- Android 2.3 代码混淆proguard技术介绍
- Android 2.3 代码混淆proguard技术介绍
- Android 2.3 代码混淆proguard技术介绍
- Android 2.3 代码混淆proguard技术介绍
- Android 2.3 代码混淆proguard技术介绍
- Android 2.3 代码混淆proguard技术介绍
- Android 2.3 代码混淆proguard技术介绍 收藏
- ProGuard代码混淆技术详解
- ProGuard代码混淆技术详解
- ProGuard代码混淆技术详解
- ProGuard代码混淆技术详解
- ProGuard代码混淆技术详解
- ProGuard代码混淆技术详解
- ProGuard代码混淆技术详解
- ProGuard代码混淆技术详解
- ProGuard代码混淆技术详解
- linux/unix下setuid/seteuid/setreuid/setresuid
- 国外优秀Windows7桌面插件RAINMETER
- 365u-boot编译
- DirectX框架之修改设备( DXUTSetCallbackDeviceChanging( ModifyDeviceSettings ) );
- CDialogBar 使用
- Android2.3 proguard介绍---代码混淆技术
- 商务版的需求场景
- ORACLE将普通表转变为分区表方法
- 如何将Android带入互联网数字家庭? 第一篇
- AutoCompleteTextView下拉框弹出时,父窗口置灰且不可点击
- 请问这个ncount为什么是输出0呢,而且find那部分会出错
- linux C 中调用新的进程 (system和execv)
- MySQL中的group_concat函数的使用方法
- CCProxy+Proxifier代理手机连接电脑(玩网游)支持VIST(防QQ不掉线)本文转载