在 Eclipse 中使用 Proguard for Android 出现错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4421262/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Using Proguard for Android in Eclipse got Error
提问by Chris
I have taken a fresh install of Eclipse and all the latest Android tools and want to use Proguard on existing project, but for now I have created a new blank one.
I have added a proguard.cfg
file to my project
added proguard.config=proguard.cfg
to my default.properties
我重新安装了 Eclipse 和所有最新的 Android 工具,并希望在现有项目中使用 Proguard,但现在我创建了一个新的空白项目。我添加了一个proguard.cfg
添加文件到我的项目proguard.config=proguard.cfg
我的default.properties
Now when I try to export I get the following error
现在,当我尝试导出时,出现以下错误
[2010-12-12 10:36:35 - ApplicationTest] Proguard returned with error code 1. See console
[2010-12-12 10:36:35 - ApplicationTest] 'C:\Program' is not recognized as an internal or external command,
[2010-12-12 10:36:35 - ApplicationTest] operable program or batch file.
[2010-12-12 10:36:35 - ApplicationTest] '-jar' is not recognized as an internal or external command,
[2010-12-12 10:36:35 - ApplicationTest] operable program or batch file.
I know it means there is a filepath setup incorrectly, question is where the heck is as I have looked through the general properties and project properties and can't see any reference to proguard or obfuscation so am stuck on what to change
我知道这意味着文件路径设置不正确,问题是我查看了一般属性和项目属性,但看不到任何对 proguard 或混淆的引用,所以我坚持要更改的内容
Any help appreciated.
任何帮助表示赞赏。
回答by Asmo Soinio
You need to define your Android SDK path without spaces. Copy&Paste from this answer by Mark:
您需要定义不带空格的 Android SDK 路径。从马克的这个答案中复制和粘贴:
Proguard error: Expecting class path seperator - not sure where I need to put a path in quotes
Proguard 错误:需要类路径分隔符 - 不确定我需要将路径放在引号中的位置
Yep, that worked for me. To put it specifically:
In Eclipse: Window > Preferences > Android > SDK Location
use something like c:\Progra~1\android-sdk (or maybe c:\Progra~2\android-sdk on 64bit)
是的,这对我有用。具体来说:
在 Eclipse 中:窗口 > 首选项 > Android > SDK 位置
使用类似 c:\Progra~1\android-sdk (或者在 64 位上使用 c:\Progra~2\android-sdk)
For me the path is "c:\Progra~1\Android\android-sdk-windows"
对我来说,路径是 "c:\Progra~1\Android\android-sdk-windows"
回答by Viktor Bre?an
According to comments posted by a Google Engineer in thread here: http://groups.google.com/group/android-developers/browse_thread/thread/19b96902fc20cede
根据谷歌工程师在此处发表的评论:http: //groups.google.com/group/android-developers/browse_thread/thread/19b96902fc20cede
*.bat file shipped with ProGuard doesn't support paths with spaces.
ProGuard 附带的 *.bat 文件不支持带空格的路径。
Having Java and Android SDK installed on paths without spaces doesn't solve the problem completely. Things can go wrong if path to eclipse workspace, temp folder or some of external JAR files contains spaces as well.
在没有空格的路径上安装 Java 和 Android SDK 并不能完全解决问题。如果 eclipse 工作区、临时文件夹或某些外部 JAR 文件的路径也包含空格,则可能会出错。
I was too lazy to re-install everything so my workaround involves making junction points on a file system.
我懒得重新安装所有东西,所以我的解决方法是在文件系统上创建连接点。
回答by Chris
I just reinstalled JAVA and ANDROID in the root directory instead of under their default paths in program files and it all worked
我只是在根目录中重新安装了 JAVA 和 ANDROID,而不是在程序文件的默认路径下,一切正常
回答by Mimminito
Is there not a way to specify the direct paths ourselves to the Java and Android SDK in the proguard config file?
有没有办法在 proguard 配置文件中自己指定 Java 和 Android SDK 的直接路径?
回答by lillicoder
This problem looks to be fixed in ADT 12. The following change in main_rules.xml solves the problem and should be included in ADT 12: https://review.source.android.com/#change,22791.
此问题在 ADT 12 中似乎已修复。 main_rules.xml 中的以下更改解决了该问题,应包含在 ADT 12 中:https://review.source.android.com/#change,22791 。
I can verify that downloading the fixed version and replacing the copy that comes with the sdk at your_sdk_path/tools/ant fixes this issue.
我可以验证下载固定版本并替换 your_sdk_path/tools/ant 中 sdk 附带的副本可以解决此问题。
回答by Hikmat Khan
OK , now i found one way to fix this problem 1, set up the "PROGUARD_HOME" EVN PATH to \tools\proguard 2, restart eclipse 3, now it work fine!
好的,现在我找到了解决此问题的一种方法 1,将“PROGUARD_HOME”EVN PATH 设置为 \tools\proguard 2,重新启动 eclipse 3,现在它可以正常工作了!
回答by RoadXY
I changed the SDK paths to the 8.3 format and changed the proguard.jar folder in proguard.bat to the 8.3 format and now all is working again!
我将 SDK 路径更改为 8.3 格式,并将 proguard.bat 中的 proguard.jar 文件夹更改为 8.3 格式,现在一切又恢复正常了!