gpt4 book ai didi

android - Proguard 收缩行为 - 二级方法

转载 作者:行者123 更新时间:2023-11-30 01:54:28 24 4
gpt4 key购买 nike

抱歉,如果这太基础了 - 我正在努力寻找我能理解的 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.

关于android - Proguard 收缩行为 - 二级方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32492636/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com