Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Proguard for Android in Eclipse got Error

Tags:

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

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

Any help appreciated.

like image 620
Chris Avatar asked Dec 12 '10 10:12

Chris


People also ask

What is ProGuard rule in Android?

ProGuard is a tool to help minify, obfuscate, and optimize your code. It is not only especially useful for reducing the overall size of your Android application as well as removing unused classes and methods that contribute towards the intrinsic 64k method limit of Android applications.

What is ProGuard usage txt?

The ProGuard tool shrinks, optimizes, and obfuscates your code by removing unused code and renaming classes, fields, and methods with semantically obscure names. The result is a smaller sized . apk file that is more difficult to reverse engineer.

Should I use ProGuard?

It is quite easy to reverse engineer Android applications, so if you want to prevent this from happening, yes, you should use ProGuard for its main function: obfuscation. ProGuard has also two other important functions: shrinking which eliminates unused code and is obviously highly useful and also optimization.


2 Answers

You need to define your Android SDK path without spaces. Copy&Paste from this answer by Mark:

Proguard error: Expecting class path seperator - not sure where I need to put a path in quotes

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)

For me the path is "c:\Progra~1\Android\android-sdk-windows"

like image 72
Asmo Soinio Avatar answered Sep 21 '22 19:09

Asmo Soinio


According to comments posted by a Google Engineer in thread here: http://groups.google.com/group/android-developers/browse_thread/thread/19b96902fc20cede

*.bat file shipped with ProGuard doesn't support paths with spaces.

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.

I was too lazy to re-install everything so my workaround involves making junction points on a file system.

like image 26
Viktor Brešan Avatar answered Sep 21 '22 19:09

Viktor Brešan