2019独角兽企业重金招聘Python工程师标准>>>

作为Android应用开发者,不得不面对一个尴尬的局面,就是自己辛辛苦苦开发的应用可以被别人很轻易的就反编译出来。Google似乎也发现了这个问题,从SDK2.3开始我们可以看到在android-sdk-windows\tools\下面多了一个proguard文件夹。proguard是一个java代码混淆的工具,通过proguard,别人即使反编译你的apk包,也只会看到一些让人很难看懂的代码,从而达到保护代码的作用。
下面具体说一说怎么样让SDK2.3下的proguard.cfg文件起作用,先来看看
android-sdk-windows\tools\lib\proguard.cfg的内容:

  view plain copy to clipboard print ?
  • -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 * extends android.app.backup.BackupAgentHelper
  • -keep public class * extends android.preference.Preference
  • -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 *;
  • }

-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 * extends android.app.backup.BackupAgentHelper-keep public class * extends android.preference.Preference-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中的例子及注释。)
让proguard.cfg起作用的做法很简单,就是在eclipse自动生成的 default.properties文件中加上一句 “ proguard.config=proguard.cfg ”就可以了
完整的 default.properties文件应该如下:

view plain copy to clipboard print ?

  • # 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
  • proguardproguard.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-9proguard.config=proguard.cfg
大功告成,正常的编译签名后就可以防止代码被反编译了。

2.3之前的SDK版本也没关系,把上面的proguard.cfg文件复制一份放到项目中,然后进行相同的操作即可。
有些应用反编译后java代码用jd-ui根本都无法打开,连混淆的代码都看不到的,本人尝试多次都做不到,希望知道的告知下怎么处理的。
   注意:上面的功能只是把java代码混淆了,xml和资源文件、图片并没有混淆,有些游戏应用图片比较重要需要转换成dat文件 再加上自己的加密解密算法还原。 另外加了混淆功能后还有压缩的功能,混淆后的apk比原来的小(具体比例看你的代码重复量了)        

转载于:https://my.oschina.net/997155658/blog/114178

如何防止apk程序被反编译相关推荐

  1. Android如何防止apk程序被反编译

    作为Android应用开发者,不得不面对一个尴尬的局面,就是自己辛辛苦苦开发的应用可以被别人很轻易的就反编译出来.Google似乎也发现了这个问题,从SDK2.3开始我们可以看到在android-sd ...

  2. Python攻防-APK批量自动反编译与数据分析

    文章目录 前言 Pull APK 1.1 根据包名列表 1.2 根据手机路径 逆向APK 2.1 自动化反编译 2.2 数据快速检索 数据分析 3.1 txt文本的比较 3.2 txt转换为xlsx ...

  3. Android APK+Dex文件反编译及回编译工具

    本帖最后由 zhu891108 于 2012-8-3 11:00 编辑 大家好! 相信很多人玩智能手机,无论是塞班,安卓等等,不只是看重各种软件的功能,而更多的是看重系统的可定制性,可以自己动手DIY ...

  4. Android APK+Dex文件反编译及回编译工具 v.1.8.0 测试版

    可显示APK文件自身图标 _______________________________________________________________________________________ ...

  5. Android APK+Dex文件反编译及回编译工具(APKDB)v.1.9.2 正式版

    http://idoog.me/?p=1913 [Android APK+Dex文件反编译及回编译工具 (APKDB)v.1.9.2 正式版] <APK+Dex文件反编译及回编译工具> 简 ...

  6. [软件共享] 【强荐】Android APK+Dex文件反编译及回编译工具 v.1.7.2 正式版

    该工具非常强大,集成了反编译和回编译APK文件的工具apktool1.3/1.43/1.50版本,可以用于编译ICS4.0和JB4.1的APK文件, 里面还有ZIP刷机包和APK文件的签名工具, 所以 ...

  7. Android APK+Dex文件反编译及回编译工具 比 APKtool GUI 好千倍

    Android APK+Dex文件反编译及回编译工具 v1.7.2 正式版                        Soyu Zom 出品 =========================== ...

  8. AutoHotKey程序防止反编译的简单手段

    可以使用AutoHotKey自带的工具. AutoHotKey安装完成后(我使用的是1.1.0.0),找到安装所在目录下的文件:\Compiler\Ahk2Exe.exe. 程序界面如下: 简单使用: ...

  9. 10分钟带你学会微信小程序的反编译

    以xxxxx小程序为例10分钟带你学会微信小程序的反编译 2019-11-28 12:59:26 以一个简单的例子介绍下小程序反编译操作流程 实验环境 前置准备 模拟器内软件安装 获取小程序包 开始解 ...

最新文章

  1. [Angular JS教程] HeroService: getHeroes failed: undefined 问题解决方法
  2. 数据库收缩:NOTRUNCATE与TRUNCATEONLY
  3. 电机控制应用中的电磁兼容性设计与测试标准
  4. C语言中长度为0的数组
  5. 单模光电转换器怎么接_以太网光纤收发器怎么用?
  6. Uva 11354 LCA 倍增祖先
  7. 高并发第一弹:准备阶段 了解高并发
  8. linux路由表生成,路由表(FIB)内容的生成(一)
  9. PHP网站后台角色权限管理系统源码
  10. jQuery formValidator表单验证插件4.1.1提供下载
  11. [微信小程序] js变量名称写活
  12. 7台不同配置M1 MacBook Pro真实测试
  13. 实现元素拖拽放大缩小_G6 3.6:放大每一处细节
  14. Httpx:针对HTTP的安全研究工具
  15. jQuery温习篇---强大的JQuery选择器
  16. Arduino-LiquidCrystal_I2C 液晶库
  17. IP修改后自动还原(IP地址无法修改)
  18. 计算机基础知识之信息技术初步
  19. 项目实战--Ego微商小程序
  20. Python一键更换证件照背景色

热门文章

  1. AI工程师面试知识点:TensorFlow 框架
  2. SAP MM PR中的Fixed ID字段与MD04里PR单据号后的星号
  3. SAP LSMW 事务代码HUPAST的录屏后台执行报错 - Runtime error RAISE_EXCEPTION has occurred - 之分析
  4. 石正丽/周鹏团队发表冠状病毒新研究,进一步证明新冠非实验室泄漏
  5. 清华微电子副所长尹首一:中国AI芯片的技术路线最全面
  6. 为什么AI感知与人类感知无法直接比较?
  7. 专业|尧德中:脑器交互学,一个发展中的新学科
  8. 人工智能、核聚变、碳捕捉……最有可能帮助拯救地球的10项技术
  9. 关于交通创新,这五大智慧城市做了啥?
  10. CICC科普栏目|神经网络浅讲:从神经元到深度学习