如何覆盖其他 proguard 规则

发布于 2025-01-17 19:28:19 字数 405 浏览 3 评论 0原文

我希望从thirdpartylib.aar中删除带有以下签名的类A

package com.example

class A : Base {}

,该带有其自己的proguard/r8规则,其中一个是

- 保存公共类 *扩展了com.example .base

但是,我希望删除A类,因为我知道这不会使用。我如何实现这一目标。

下面的规则不起作用,因为为什么areyoukeping散发出上述规则。

-keep class!com.example.a

我试图弄清楚proguard规则是否优先。是否可以将规则声明为更高的优先级?提前致谢。

I wish to remove a class A with the following signature

package com.example

class A : Base {}

from a thirdpartylib.aar that comes with its own set of proguard/r8 rules one of which is

-keep public class * extends com.example.Base

however I wish to remove a class A since I know this wouldn't be used. How do I achieve this override.

The rule below doesn't work, since whyareyoukeeping emits the rule above.

-keep class !com.example.A

I'm trying to figure out if there is a priority to proguard rules. Is it possible to declare a rule as higher priority? Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凶凌 2025-01-24 19:28:19

首先,规则的“优先”是最广泛的规则优先。因此,如果一条规则保留某些东西,则不可能将另一个规则远离。

目前,覆盖jar's/aar's中包含的规则的唯一方法是分叉并替换规则。可以通过替换版本的本地Maven存储库来实现这一目标。

但是,AGP 7.3将包含库中的重大规则的功能,请参见 https://issuetracker.google.com/37097003 < /a>有关更多详细信息。可以通过AGP 7.3金丝雀尝试一下。

First of all the "priority" of rules is that the most broad rule takes precedence. So if a rule keeps something it is not possible for another rule to take that keep away.

Right now the only way to override the rules included in a jar's/aar's is to fork it and replace the rules. One can do that through a local maven repository with a replacement version.

However, AGP 7.3 will include a feature for overriding rules in libraries, see https://issuetracker.google.com/37097003 for more details. It is possible to try out this through the AGP 7.3 canaries.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文