ProGuard中keep到底有什么作用
一直以为keep就是不要混淆 近期发现还有另外一个作用 见官方文档
Testing your app should reveal any errors caused by inappropriately removed code, but you can also inspect what code was removed by generating a report of removed code.
To fix errors and force R8 to keep certain code, add a -keep line in the ProGuard rules file. For example:
-keep public class MyClass
Alternatively, you can add the Keep annotation to the code you want to keep. Adding Keep on a class keeps the entire class as-is. Adding it on a method or field will keep the method/field (and its name) as well as the class name intact. Note that this annotation is available only when using the AndroidX Annotations Library and when you include the ProGuard rules file that is packaged with the Android Gradle plugin, as described in the section about how to enable shrinking.
仔细读会发现keep作用是不被任何优化 除了混淆还有删除 因为ProGuard的过程中会清理没有使用的类或方法等代码 设置keep后 这部分就不会被作任何优化 包括被清理
ProGuard混淆 ProGuard技术的功能概括为以下4项: 1.压缩(shrinks) :检查并移除代码中无用的类,字段,方法,属性。 2.优化(optimizes):对字节码进行优化,移除无用的指令。 3.混淆(obfuscates):使用a,b,c,d等简短而无意义的名称,对类,字段和方法进行重名,这样即使代码被逆向工程,对方也比较难以读懂。 4.预检测(Preveirfy):在java平台上对处理后的代码进行再次检测。 (1) ProGuard 配置 -include{filename}:从给定的文件中读取配置参数。 -basedirectory{directoryname}:指定基础目录为
相关文章
- 英伟达 GPU 中的 Tensor Cores有什么作用?
- 吉他谱Guitar pro是什么软件及功能作用介绍
- js代码中的parent,top和self有什么区别
- 科技巨头争抢的“超级账本”,到底是个什么组织?
- 面试官:jwt 是什么?java-jwt 呢?懵逼了。。
- JSON是什么,为什么这么流行?
- 年薪高达50W的测开,到底是做什么的?
- 软件测试中的测试计划和测试用例起到什么作用?
- jsp 有哪些动作?作用分别是什么?
- 什么是网关及网关作用
- MySQL中的外键是什么、有什么作用
- 【TensorFlow 基础练习】查看本机TensorFlow是普通版本还是GPU版本,几个错误记录,神经网络干了什么,Tensorflow的处理结构,张量Tensor,对于Tensorflow的测试
- 【Idea】Process finished with exit code 0 是什么意思?
- 什么是软件安全测试,安全测试报告有什么作用,主要测试哪些内容?
- BI对企业到底有什么作用?
- 架构漫谈(六):软件架构到底是要解决什么问题?
- 什么是CAN总线
- 详谈OC(object-c)深浅复制/拷贝-什么情况下用retain和copy
- 什么是m3u8、f4v格式的文件
- .net framework 4.8是什么,用于哪些方面,作用在哪
- viewpager的setOffscreenPageLimit方法有什么作用
- 内存XMP是什么意思?有必要开吗?内存XMP模式的作用与开启教程
- __declspec,__cdecl,__stdcall都是什么意思?有什么作用?
- hibernate的load和get有什么作用
- 【集合我能讲两小时058】为什么不直接序列化elementData,这样设计有什么好处吗?