Android库Proguard程序包混淆会产生a.a.a.a.a冲突 [英] Android library proguard package obfuscation produces a.a.a.a.a collision

查看:1511
本文介绍了Android库Proguard程序包混淆会产生a.a.a.a.a冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写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.amy.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文件中,同时分别用12替换#来解决.这会将所有混淆的类移到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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆