Android库Proguard程序包混淆会产生a.a.a.a.a冲突

我正在编写2个Android库.当我对两者进行混淆时,它们两者中的混淆代码都包含一个名为a.a.a.a.a的类,当尝试在同一应用程序中使用这两个库时,会导致以下错误:

在模块classes.jar(lib1)和classes.jar(lib2)中找到重复的class a.a.a.a

如何防止Proguard混淆前三个软件包而最终导致:

my.domain.lib1.a.a和my.domain.lib2.a.a?

编辑:混淆是在构建库时发生的,而不是在构建应用程序时发生的.

解决方案
这可以通过将-repackageclasses my.domain.lib#.ofs放入每个库的proguard-rules文件中,同时分别用1和2替换#来解决.这会将所有混淆的类移到my.domain.lib#.ofs包中,而所有未混淆的类将保留在其原始包中,并且确保没有冲突.

Proguard 文档指出:

-重新包装类[package_name]

指定将所有重命名的类文件重新打包,方法是将它们移到单个给定的包中.

另一种解决方案是使用-keeppackagenames.不幸的是,我找不到让仅保留前三个软件包的方法.

请参见Proguard 文档:

-keeppackagenames [package_filter]

指定不混淆给定的程序包名称.

原文
I’m writing 2 Android libraries. When I obfuscate both, the obfuscated code in both of them contains a class named a.a.a.a.a which causes the following error when trying to use both libraries in the same application:

Duplicate class a.a.a.a.a found in modules classes.jar (lib1) and classes.jar (lib2)

How can I prevent Proguard from obfuscating the first 3 packages to end up with:

my.domain.lib1.a.a and my.domain.lib2.a.a?

Edit: The obfuscation is happening as part of building the libraries, not while building the application.

解决方案
This can be resolved by putting -repackageclasses my.domain.lib#.ofs in the proguard-rules file of each library while replaceing # with 1 and 2 respectivly. This will move all the obfuscated classes into the my.domain.lib#.ofs package while all the non-obfuscated classes will remain in their original packages and you’re guaranteed to have no collisions.

As the Proguard documentation states:

-repackageclasses [package_name]

Specifies to repackage all class files that are renamed, by moving them into the single given package.

Another solution is to use -keeppackagenames. Unfortunately, I couldn’t find a way to make it keep only the first 3 packages.

See the Proguard documentation:

-keeppackagenames [package_filter]

Specifies not to obfuscate the given package names.

本文地址:IT屋 » Android库Proguard程序包混淆会产生a.a.a.a.a冲突
https://www.it1352.com/1915502.html

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值