Sunday, December 12, 2010

Proguard Integration in Gingerbread

The new android gingerbread 2.3 sdk doesn't have many front end user enhancements, but the backend enhancements for gaming and developers are superb. One important new feature is Proguard integration. What used to be many steps in setting up Proguard and configuring the properties files is one only now a two step process. I just want to share what I've learned in setting up Proguard in Eclipse.

First off, if you haven't already, read the android developers Proguard article for an introduction and overview of how to set it up in Eclipse. http://developer.android.com/guide/developing/tools/proguard.html

The jist of it is, in your default.properties file, just add a new entry for proguard.config set equal to the location of your proguard.cfg. If you have any special obfuscation configuration/exceptions, you can include it in the .cfg file. Read the proguard doc for more detailed information.

You're not ready to export your application yet. You need to create a new system variable (Windows: Control Panel->Advanced system settings, Advanced (tab)->Environment Variables->New...(under System variables). Set up the Variable name as "PROGUARD_HOME", and Variable value as \tools\proguard (for instance, my android sdk is located in c:\android, so my Variable value would be "c:\android\tools\proguard"). For Mac/Linux, if you are using those OSes, then you should know how to add the Environment variables there.

If you have Eclipse running while you are doing these procedures, restart it. You should be able to export your application now. Otherwise you will get the this ugly mess
eclipse.buildId=M20100909-0800
java.version=1.6.0_12
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Framework arguments: -product org.eclipse.epp.package.java.product
Command-line arguments: -os win32 -ws win32 -arch x86 -product org.eclipse.epp.package.java.product


Error
Sun Dec 12 20:57:31 PST 2010
Failed to export application

com.android.ide.eclipse.adt.internal.build.ProguardResultException
at com.android.ide.eclipse.adt.internal.build.BuildHelper.runProguard(Unknown Source)
at com.android.ide.eclipse.adt.internal.project.ExportHelper.exportReleaseApk(Unknown Source)
at com.android.ide.eclipse.adt.internal.wizards.export.ExportWizard.doExport(Unknown Source)
at com.android.ide.eclipse.adt.internal.wizards.export.ExportWizard.access$0(Unknown Source)
at com.android.ide.eclipse.adt.internal.wizards.export.ExportWizard$1.run(Unknown Source)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
Happy coding and thank you Google for making it so much easier! I spent hours trying to re-setup and publish my app on a new Windows 7 install and this saved me the trouble.

Update: credit to this post for the fix http://osdir.com/ml/Android-Developers/2010-12/msg00965.html

1 comment:

  1. Although having very similar names, Java and JavaScript are totally two different

    languages separately but they are able to create the web-based applications.

    JavaScript is supported by all browsers, but Java is not.To learn more:

    java training

    ReplyDelete