Android库Proguard程序包混淆会产生a.a.a.a.a冲突 [英] Android library proguard package obfuscation produces a.a.a.a.a collision
问题描述
我正在编写2个Android库.当我对两者进行混淆时,它们两者中的混淆代码都包含一个名为a.a.a.a.a
的类,当尝试在同一应用程序中使用这两个库时,会导致以下错误:
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:
在模块classes.jar(lib1)和classes.jar(lib2)中找到重复的class a.a.a.a
Duplicate class a.a.a.a.a found in modules classes.jar (lib1) and classes.jar (lib2)
如何防止Proguard
混淆前三个软件包而最终导致:
How can I prevent Proguard
from obfuscating the first 3 packages to end up with:
my.domain.lib1.a.a
和my.domain.lib2.a.a
?
编辑:混淆是在构建库时发生的,而不是在构建应用程序时发生的.
The obfuscation is happening as part of building the libraries, not while building the application.
推荐答案
这可以通过将-repackageclasses my.domain.lib#.ofs
放入每个库的proguard-rules
文件中,同时分别用1
和2
替换#
来解决.这会将所有混淆的类移到my.domain.lib#.ofs
包中,而所有未混淆的类将保留在其原始包中,并且确保没有冲突.
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.
Proguard
文档指出:
-重新包装类[package_name]
指定将所有重命名的类文件重新打包,方法是将它们移到单个给定的包中.
Specifies to repackage all class files that are renamed, by moving them into the single given package.
另一种解决方案是使用-keeppackagenames
.不幸的是,我找不到让仅保留前三个软件包的方法.
Another solution is to use -keeppackagenames
. Unfortunately, I couldn't find a way to make it keep only the first 3 packages.
请参见Proguard
文档:
-keeppackagenames [package_filter]
指定不混淆给定的程序包名称.
Specifies not to obfuscate the given package names.
这篇关于Android库Proguard程序包混淆会产生a.a.a.a.a冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!