防止Android应用被编译

上传人:gg****m 文档编号:214296735 上传时间:2021-11-23 格式:DOCX 页数:2 大小:66.72KB
返回 下载 相关 举报
防止Android应用被编译_第1页
第1页 / 共2页
防止Android应用被编译_第2页
第2页 / 共2页
亲,该文档总共2页,全部预览完了,如果喜欢就下载吧!
资源描述

《防止Android应用被编译》由会员分享,可在线阅读,更多相关《防止Android应用被编译(2页珍藏版)》请在金锄头文库上搜索。

1、如何防止Android应用被反编译2011年7月12日iStar发表评论 阅读评论作为Android应用开发者,不得不面对一个尴尬的局面,就是自己辛辛苦苦开发 的应用可以被别人很轻易的就反编译出來。Google似乎也发现了这个问题,从 SDK2. 3开始我们可以看到在android-sdk-windows/tools/下面多了一个 proguard文件 夹,proguard是一个java代码混淆的工具,通proguard,别 人即使反编译你的apk包,也只会看到一些让人很难看懂的代码,从而达到保护 代码的作用。卜面具体说一说怎么样让SDK2. 3下的proguard, cfg文件起作用,先來看

2、看 proguard, cfg 的内容:-optimizationpasses 5-dontusemixedcaseclassnames -dontsk i pnonpubliclibraryclasses-dontpreverify-verbose-optimizations !code/simplification/arithmetic, !field/*, !class/mergin g/*-keep public-keep public-keep public-keep public-keep public-keep publicclass class class class clas

3、s class*extends extends extends extends extendsandroid, app. Activity android, app. Application android, app. Service android, content. BroadcastReceiver android, content. ContentProvidercom android. vending. 1icensing. TLicensingService-keepclasseswithmembernames class * native methods;-keepclasses

4、withmembernames class * publ ic (android, content. Context, android, util. AttributeSet); -keepclasscswithnicmbcrnanics class * public (android, content. Context, android, util. AttributeSet, int);-keepclassmembers enum * public static * values(); public static * valueOf (java. lang. String);-keep c

5、lass * implements android, os. Parcelable public static final android, os. Parcelable$Creator *;从脚本中可以看到,混淆中保留了继承自Activity、Service、Application、 BroadcastReceiver ContentProvider 等基木组件以及com. an droid, vendin g. 1 icens ing. TLice ns in gService, 并保 留 了所有 的 Native变量名及类名,所有类中部分以设定了固定参数格式的构造函数,枚举 等等。(详细

6、信息请参考/examplcs中的例子及注释。)让proguard, cfg起作用的做法很简单,就是在eclipse自动生成的 default, properties 文件中力口上一句 uproguard, config=proguard. cfg” 就可 以了,完整的default, properties文件应该如下:# This file is auto matically gen emted by An droid Tools.# Do not modify this file YOUR CHANGES WILL BE ERASED!# This file must be checked

7、in Version Control Systems.# To customizc properties used by the Ant build system use,# z,build. properties, and override values to adapt the script to your# project structure.# Project target.target=androi d-9proguard, config二proguard, cfg大功告成,正常的编译签名后就可以防止代码被反编译了。反编译经过代码混淆 的apk得到的代码应该类似于下面的效果,是很难看懂的:日曲 zy.MyProguard&-J MyProguard MyProguardG onCreate(Bundle) : voidE)-0 ao a : String o b : into c : floata .class x MyP roguard.classpackage zy.MyPrcguard;public final class apublic String a;public int b;public float c;如果您使用的是2. 3之前的SDK版本也没关系,把上面的proguard, cfg文件复 制一份放到项目中,然后进行相同的操作即可。

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 办公文档 > 其它办公文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号