Proguard:避免使用预先混淆的库JAR命名冲突 [英] Proguard: avoiding naming collisions with pre-obfuscated library JARs

查看:640
本文介绍了Proguard:避免使用预先混淆的库JAR命名冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎Proguard在重命名/重新打包类时没有尝试避免命名与库JAR中的类的冲突。这是正确的,还是我没有正确配置?

It seems that Proguard doesn't make any attempt to avoid naming collisions with classes in library JARs when it renames/repackages classes. Is this correct, or have I just not configured it correctly?

我混淆了使用最新Google AdMob SDK的Android应用程序。以前我使用旧的AdMob SDK没有问题。新的SDK JAR文件包含一些已被混淆的类。其中一个类是默认/未命名包中的 a.class 。当我混淆我的应用程序时,Proguard重命名/重新打包我的一个类,在未命名的包中也是 a.class ,尽管已将AdMob JAR作为库JAR读入(所以它应该知道这会导致碰撞)。可以预见,当 dx 工具尝试在单个.dex文件中组合这两个具有相同名称的类时,我的构建失败。

I am obfuscating an Android application that uses the latest Google AdMob SDK. Previously I was using the old AdMob SDK without a problem. The new SDK JAR file contains some classes that have been obfuscated. One of these classes is a.class in the default/unnamed package. When I obfuscate my app, Proguard renames/repackages one of my classes to also be a.class in the unnamed package, despite having read in the AdMob JAR as a library JAR (so it ought to know that this will cause a collision). Predictably, my build fails when the dx tool attempts to combine these two identically named classes in a single .dex file.

作为一种解决方法,我已经重新配置了Proguard,以便它将我的所有类移动到一个命名包(只是一个字母),以避免与Google类冲突,但我很想知道是否有更好的解决方案或是否这是Proguard当前版本(4.6)的限制吗?

As a workaround I have reconfigured Proguard so that it moves all of my classes into a named package (just a single letter) to avoid collisions with the Google classes, but I'm interested to know if there is a better solution or if this is a limitation of the current version (4.6) of Proguard?

推荐答案

来自progaurd 手册

From the progaurd manual,


如果输入jar和库jar包含同一个包中的类,则模糊输出jar可能包含与库jar中的类名重叠的类名。这很可能是因为库jar之前已经被混淆了,因为它可能包含名为'a','b'等的类。因此,包不应该被分成输入罐和库罐。

If an input jar and a library jar contain classes in the same package, the obfuscated output jar may contain class names that overlap with class names in the library jar. This is most likely if the library jar has been obfuscated before, as it will then probably contain classes named 'a', 'b', etc. Packages should therefore never be split across input jars and library jars.

所以看起来使用自己的包是建议的答案。

So it looks like using your own package is the recommended answer.

这篇关于Proguard:避免使用预先混淆的库JAR命名冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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