Android开发代码混淆经验(Eclipse)
2015-11-09 14:14
645 查看
为了防止自己的劳动成果被别人窃取,混淆代码能有效防止被反编译,下面来总结以下混淆代码的步骤:
2、编辑项目下的proguard-project.txt,添加不需要混淆的规则(model、泛型、反射、第三方jar包),proguard-project.txt文件内容如下:
技巧:第三方jar包包名可以用WinRAR来打开jar文件,获取包路径。例如:jtds-1.2.jar,用WinRAR查看,可以发现包名为:net.sourceforge.jtds,所以只需要添加如下2行代码,即可不混淆该jar文件的相关包和类:
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、/content/3649915.html
相关文章推荐
- 手机安全卫士简单实现原理
- Android SDK Timer的schedule()方法的正确使用
- Android:onNewIntent()触发机制及注意事项
- Android小记:Android入门教程
- Android 使用SQLiteOpenHelper打开SD卡上的数据库
- Android 之 下拉框(Spinner)的使用
- Android开发之创建Fragment
- android shape的使用
- 安卓 图片处理
- 在android studio 1.4.1中使用opencv
- android开发较好的blog
- Android 通知栏Notification的整合 全面学习 (一个DEMO让你完全了解它)
- 命令行更新android sdk + gradle设置代理
- adt-bundle android-studio sdk 下载地址
- Android -- ViewDragHelper
- android orm工具GreenDao的使用
- Android沉浸式状态栏的实现
- android 源码下载备忘
- android------通用ViewHolder 通用Adapter
- Android编程实现两个Activity之间共享数据及互相访问的方法