在 Eclipse 中使用 ProGuard(无需私钥)
我一直在尝试在我的测试 Android 应用程序中查看 ProGuard 的运行情况。我是否需要注册为 Android 开发者并拥有密钥才能完成此操作?我知道应用程序需要在发布模式下构建。我在 Android 网站上多次阅读了这些说明,其中包括关于 ProGuard 的作用,但不包括如何在 Android 中正确实现混淆。找到另一个 博客 展示了如何使用 Ant 进行操作,但不适用于 Eclipse。
I've been trying to see ProGuard in action with my test Android app. Do I need to register as an Android developer and have a key to do that? I know app needs to be built in release mode. I read these instructions several times on Android site among other things, it talks about what ProGuard does but not how to achieve it obfuscation in Android properly. Found another blog that shows how to do it with Ant, but not with Eclipse.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不,您不需要注册为 Android 开发人员来尝试 Proguard 混淆。您只需要为您的应用程序安装并正确配置 Proguard。
几个月以来,Android SDK 附带了直接集成的 Proguard 发行版。打开
\tools
目录并检查是否在其中找到名为proguard
的目录。如果不是这种情况,最好是升级您的 SDK。在 Android SDK 的集成版本中使用 Proguard 非常简单:您只需在项目的
default.properties
文件中声明以下内容:然后,您必须编写您的
proguard。 cfg
(如果尚不存在)。 Android SDK 会为您创建的任何新项目编写此文件,因为它集成了 Proguard,但如果您的项目是使用以前版本的 SDK 创建的,则此文件将不存在。以下文件适用于大多数 Android 项目:当您在调试模式下编译时,不会出现混淆。要混淆代码,您必须:
1- 确保清单文件将调试模式设置为 false:
2- 使用 Eclipse 的“文件/导出”菜单导出 APK(前提是您使用 Eclipse,但谁不使用 Eclipse) :-))。仅使用“运行”功能不会造成混淆,因为这实际上是在调试。
完成混淆后,您将在项目的根目录中找到一个
proguard
目录。它将包含允许您检查混淆代码的文件,查看混淆的内容和未混淆的内容等。Proguard 的文档将在这方面为您提供帮助,这非常简单。No, you do not need to register as an Android developper to try the Proguard obfuscation. You just need to have Proguard installed and properly configured for your app.
Since a few month, the Android SDK comes with a distribution of Proguard directly integrated. Open your
<android-home>\tools
directory and check whether you find a directory calledproguard
in it. If it is not the case, the best is to upgrade your SDK.Using Proguard is very simple with the integrated version of the Android SDK: you just have to declare what follows in the file
default.properties
of your project:Then, you have to write your
proguard.cfg
if it does not already exist. The Android SDK writes this file for you for any new project you create since it integrates Proguard, but if your project was created with a former version of the SDK this file won't exist. The following file is suitable for most Android projects:When you compile in debug mode, there is no obfuscation. To obfuscate your code, you have to:
1- Ensure that your manifest file sets the debug mode to false:
2- Export your APK using the "File/Export" menu of Eclipse (provided you are using Eclipse, but who doesn't? :-) ). There will be no obfuscation by just using the "Run" function as this is actually debugging.
Once done the obfuscation, you will find a
proguard
directory in your project's root directory. It will contain files that will allow you to inspect the obfuscated code, see what was obfuscated and what wasn't, etc. The Proguard's documentation will help you on that, that's pretty simple.