Proguard 收缩行为 - 二级方法
Proguard shrinking behavior - 2nd level methods
抱歉,如果这太基础了 - 我正在努力寻找我能理解的 Proguard 文档。
我对 Proguard 如何缩小 Android 应用程序的理解是寻找未使用(未调用?)的方法并将它们从构建中删除。因此,如果我有一个方法 buynewCoke() 从未在代码中的其他任何地方调用过,它将被删除。
但是,如果存在调用 buyNewCoke() 的方法,比如 visitStoreAfterMidnight() 会怎么样。并且从不调用 visitStoreAfterMidnight 本身。 Proguard 是否仍然删除这两种方法?还是它保留 buyNewCoke() 是因为它被某些东西引用了?
也就是说,如果 A 调用 B 而没有任何东西调用 A,那么 Proguard 的行为如何?
visitStoreAfterMidnight()
和 buyNewCoke()
都将被删除。
其实它的工作原理类似于垃圾回收,它从需要保留的东西开始,检查他们使用了什么,只保留这些。
编辑:
官方参考:
http://proguard.sourceforge.net/manual/introduction.html
Entry points
In order to determine which code has to be preserved and which code
can be discarded or obfuscated, you have to specify one or more entry
points to your code. These entry points are typically classes with
main methods, applets, midlets, activities, etc.
In the shrinking step, ProGuard starts from these seeds and
recursively determines which classes and class members are used. All
other classes and class members are discarded.
抱歉,如果这太基础了 - 我正在努力寻找我能理解的 Proguard 文档。
我对 Proguard 如何缩小 Android 应用程序的理解是寻找未使用(未调用?)的方法并将它们从构建中删除。因此,如果我有一个方法 buynewCoke() 从未在代码中的其他任何地方调用过,它将被删除。
但是,如果存在调用 buyNewCoke() 的方法,比如 visitStoreAfterMidnight() 会怎么样。并且从不调用 visitStoreAfterMidnight 本身。 Proguard 是否仍然删除这两种方法?还是它保留 buyNewCoke() 是因为它被某些东西引用了?
也就是说,如果 A 调用 B 而没有任何东西调用 A,那么 Proguard 的行为如何?
visitStoreAfterMidnight()
和 buyNewCoke()
都将被删除。
其实它的工作原理类似于垃圾回收,它从需要保留的东西开始,检查他们使用了什么,只保留这些。
编辑:
官方参考: http://proguard.sourceforge.net/manual/introduction.html
Entry points
In order to determine which code has to be preserved and which code can be discarded or obfuscated, you have to specify one or more entry points to your code. These entry points are typically classes with main methods, applets, midlets, activities, etc.
In the shrinking step, ProGuard starts from these seeds and recursively determines which classes and class members are used. All other classes and class members are discarded.