导出签名、混淆的 Android 应用程序时如何在 Eclipse 中设置 ProGuard?
我正在发布一个在 Eclipse 中开发的 Android 应用程序,正如标题中所述,我想将 Proguard 混淆集成到构建中,专门用于导出签名的应用程序。
有人没有走过蚂蚁之路吗?
I'm publishing an Android application developed in Eclipse and, as stated in the title, I would like to integrate Proguard obfuscation into the build, specifically for exporting a signed app.
Anyone had any luck without going down the ant path?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我还想在不使用 Ant 或命令行方法的情况下完成此操作。以下是有效的(仅在 Eclipse + Windows 上):
(您需要下载 Proguard。脚本期望在此处找到它:C:\android-sdk_r04-windows\proguard\lib\proguard.jar)。
创建 Windows 批处理文件,“C:\android-sdk_r04-windows\obfusc.bat”:
确保此构建工具位于最后一个,就在 Android 软件包生成器之前。
在 Android 项目的根文件夹中创建一个 proguard 配置文件。我稍微定制了这些并将它们包含在修订控制中,但这取决于您。我使用的文件名为“android.pro”,如脚本中所命名,与开发博客中的配置类似,但包含带有 injar、outjar 和 libraryjar 语句的标头,例如:
我想就是这样。
I also wanted to do this without using Ant or the command line approach. Here is what worked (on Eclipse + Windows only):
(You need to download Proguard. The script expects to find it here: C:\android-sdk_r04-windows\proguard\lib\proguard.jar).
Create a Windows batch file, "C:\android-sdk_r04-windows\obfusc.bat":
In Eclipse, bring up the properties page of your Android project, select the "Builders" pane and add a new builder of type "Program." In the "Location" field of the main tab put the absolute path of the script in the previous step. In the "Working directory" field put the variable ${build_project}. In the "Build options" tab select "After a clean" under "Run builder."
Make sure this build tool comes next to last, just before the Android package builder.
Create a proguard config file in the root folder of the Android project. I customize these slightly and include them in revision control, but that's up to you. The file I use is called "android.pro," as named in the script, and is similar to the config in the dev blog but includes a header with injar, outjar, and libraryjar statements, for example:
I think that's about it.
好的,这是关于该主题的最相关和最新的帖子:
http://android-developers.blogspot.com/2010/09/proguard-android-and-licensing-server.html
它确实使用了 Ant,但所有困难的部分都为你完成了,只要你按照说明操作,它就会起作用。注意:不要跳过更新,这仅适用于 SDK r7+,并且运行 eclipse 的更新也不是一个坏主意,对于 AVD 更新也是如此。
并且,对于任何添加外部 jar 的人,请设置 ProGuards procfg.txt 并添加:
-libraryjars {path}{file_name}.jar
Ok, this is the most relevant and recent post on the topic:
http://android-developers.blogspot.com/2010/09/proguard-android-and-licensing-server.html
It dose use Ant, but all the hard parts are done for you, and as long as you follow the instruction, it works. A note: don't skip the update this only work with SDK r7+, and it's not a bad idea to run eclipse's update, for the AVD update too.
And, for anyone adding external jars, setup ProGuards procfg.txt and add:
-libraryjars {path}{file_name}.jar
如果您使用的是 eclipse,只需取消注释
project.properties
行If you are using eclipse just uncomment the
project.properties
line