Android Proguard 如何混淆package name
来源:互联网 发布:简单力学分析软件 编辑:程序博客网 时间:2024/06/04 01:36
一、在Android 的proguard-project.txt 文件里我们可以看到如下选项:
参考 http://proguard.sourceforge.net/manual/usage.html#keeppackagenames
-keeppackagenames [package_filter]
Specifies not to obfuscate the given package names. The optional filter is a comma-separated list of package names. Package names can contain ?, *, and ** wildcards, and they can be preceded by the ! negator. Only applicable when obfuscating.
-flattenpackagehierarchy [package_name]
Specifies to repackage all packages that are renamed, by moving them into the single given parent package. Without argument or with an empty string (''), the packages are moved into the root package. This option is one example of further obfuscating package names. It can make the processed code smaller and less comprehensible. Only applicable when obfuscating.
-repackageclasses [package_name]
By default, packages that contain classes that can't be renamed aren't renamed either, and the package hierarchy is preserved. (因此我们想到另外一种不让包名被混淆的方法:即在每个package 下放一个空的class指定为不混淆,这样整个package name就会保留,不会把包名也混淆掉)Specifies to repackage all class files that are renamed, by moving them into the single given package. Without argument or with an empty string (''), the package is removed completely. This option overrides the -flattenpackagehierarchy option. It is another example of further obfuscating package names. It can make the processed code even smaller and less comprehensible. Its deprecated name is -defaultpackage. Only applicable when obfuscating.
Counter-indication: classes that look for resource files in their package directories will no longer work properly if they are moved elsewhere. When in doubt, just leave the packaging untouched by not using this option.
二、具体使用方法:Obfuscating package names
参考 http://proguard.sourceforge.net/manual/examples.html#repackaging
Package names can be obfuscated in various ways, with increasing levels of obfuscation and compactness. For example, consider the following classes:
mycompany.myapplication.MyMainmycompany.myapplication.Foomycompany.myapplication.Barmycompany.myapplication.extra.FirstExtramycompany.myapplication.extra.SecondExtramycompany.util.FirstUtilmycompany.util.SecondUtil
Let's assume the class name mycompany.myapplication.MyMain
is the main application class that is kept by the configuration. All other class names can be obfuscated.
By default, packages that contain classes that can't be renamed aren't renamed either, and the package hierarchy is preserved.This results in obfuscated class names like these:
mycompany.myapplication.MyMainmycompany.myapplication.amycompany.myapplication.bmycompany.myapplication.a.amycompany.myapplication.a.bmycompany.a.amycompany.a.b
The -flattenpackagehierarchy
option obfuscates the package names further, by flattening the package hierarchy of obfuscated packages:
-flattenpackagehierarchy 'myobfuscated'
The obfuscated class names then look as follows:
mycompany.myapplication.MyMainmycompany.myapplication.amycompany.myapplication.bmyobfuscated.a.amyobfuscated.a.bmyobfuscated.b.amyobfuscated.b.b
Alternatively, the -repackageclasses
option obfuscates the entire packaging, by combining obfuscated classes into a single package:
-repackageclasses 'myobfuscated'The obfuscated class names then look as follows:
mycompany.myapplication.MyMainmycompany.myapplication.amycompany.myapplication.bmyobfuscated.amyobfuscated.bmyobfuscated.cmyobfuscated.d
Additionally specifying the -allowaccessmodification
option allows access permissions of classes and class members to be broadened, opening up the opportunity to repackage all obfuscated classes:
-repackageclasses 'myobfuscated'-allowaccessmodificationThe obfuscated class names then look as follows:
mycompany.myapplication.MyMainmyobfuscated.amyobfuscated.bmyobfuscated.cmyobfuscated.dmyobfuscated.emyobfuscated.f
The specified target package can always be the root package. For instance:
-repackageclasses ''-allowaccessmodificationThe obfuscated class names are then the shortest possible names:
mycompany.myapplication.MyMainabcdef
Note that not all levels of obfuscation of package names may be acceptable for all code. Notably, you may have to take into account that your application may contain resource files that have to be adapted.
- Android Proguard 如何混淆package name
- 如何混淆Android项目代码(ProGuard)
- 如何混淆Android项目代码(ProGuard)
- 如何混淆Android项目代码(ProGuard)
- android 代码混淆proguard
- Android Java混淆(ProGuard)
- Android Java混淆(ProGuard)
- android 混淆器(ProGuard)
- Proguard混淆器Android
- android 混淆器(ProGuard)
- Android Java混淆(ProGuard)
- Android 混淆器 - ProGuard
- android 混淆 proguard
- Android Java混淆(ProGuard)
- android 混淆器(ProGuard)
- Android 混淆器 - ProGuard
- android 代码混淆proguard
- Android proguard代码混淆
- Java垃圾回收机制
- org.springframework.transaction.UnexpectedRollbackException: Transaction rolled back because it has
- python中格式化字符串
- struts 中继承ActionSupport类 HelloWorld!aliasAction.action
- 安卓:bindService播放指定音乐
- Android Proguard 如何混淆package name
- SOCKET:SO_LINGER 选项
- UVA 12716 GCD XOR
- jQuery.validate.js第二次调用validate()方法时,返回值错误bug解决
- spring笔记 多线程的支持
- Android studio 导入工程 出现错误
- ReactJs 技巧
- 关于csdn的赵老师
- 老D的博客