如何通过Eclipse混淆带有Proguard的apk?

时间:2011-01-27 10:26:50

标签: android eclipse proguard

我将proguard.config=proguard.cfg添加到我的default.properties文件中,并在项目根目录中有一个proguard.cfg文件。如果我现在在Eclipse中使用Export as Android Application,我会收到以下错误:

[2011-01-27 11:11:37 - Application] Warning: class [classes/com/package.Class.class] unexpectedly contains class [com/package.Class]
[2011-01-27 11:11:37 - Application] Warning: class [classes/com/package.Class2.class] unexpectedly contains class [com/package.Class2]
[2011-01-27 11:11:37 - Application] Note: there were 145 duplicate class definitions.
[2011-01-27 11:11:37 - Application] Warning: there were 146 classes in incorrectly named files.
[2011-01-27 11:11:37 - Application]          You should make sure all file names correspond to their class names.
[2011-01-27 11:11:37 - Application]          The directory hierarchies must correspond to the package hierarchies.
[2011-01-27 11:11:37 - Application]          If you don't mind the mentioned classes not being written out,
[2011-01-27 11:11:37 - Application]          you could try your luck using the '-ignorewarnings' option.
[2011-01-27 11:11:37 - Application] java.io.IOException: Please correct the above warnings first.
[2011-01-27 11:11:37 - Application]     at proguard.InputReader.execute(InputReader.java:133)
[2011-01-27 11:11:37 - Application]     at proguard.ProGuard.readInput(ProGuard.java:195)
[2011-01-27 11:11:37 - Application]     at proguard.ProGuard.execute(ProGuard.java:78)
[2011-01-27 11:11:37 - Application]     at proguard.ProGuard.main(ProGuard.java:499)

似乎我的类以某种方式保存在类子文件夹中,但Proguard将此类子文件夹用作包。因此,Proguard无法理解类的定义。

这是我的SDK设置的问题吗?或者我的Proguard配置中是否存在导致此问题的错误?

3 个答案:

答案 0 :(得分:1)

我从去年五月为我工作的东西稍微改变了proguard.cfg现在它的工作原理:

-injars bin

-injars bin/classes

我还需要清理一下 - 删除Junit(这个项目中没有使用)和兼容性库(我可能已经忽略了,但选择完全放弃)。

答案 1 :(得分:0)

现在这很方便我刚刚更新到新的ddms Eclipse插件版本:Android DDMS 9.0.0.v201101191456-93220并将我的SDK更新到包含Honeycomb的新版本,问题似乎已经消失。

答案 2 :(得分:0)

获取o​​bfusticated的步骤apk:

1)从“http://sourceforge.net/projects/proguard/files/”下载最新的程序。目前最新版本是proguard4.7

2)用最新下载的proguard文件夹替换“C:\ Program Files(x86)\ Android \ android-sdk \ tools \ proguard”的“bin”和“lib”文件夹。

3)在eclipse中检查SDK位置,查看其中的空白区域,然后转到窗口>偏好> Android系统。如果有空格,则将其替换为:

    c:\Progra~2\android\android-sdk (for windows 64-bit)
    c:\Progra~1\android\android-sdk (for windows 32-bit)

4)检查proguard.cfg文件是否在项目的根文件夹中,并在android项目的project.properties文件中添加“proguard.config = proguard.cfg”。

5)现在导出你的项目以获得obfusticated apk。

我希望它会有所帮助。