Android Build DEX Failed Error

I just purchased and imported GyroDroid into a new Unity 3.5.6f4 project on a WinXP SP3 machine. I have the latest JRE6 installed. When I try to build the project for Android, I get the error indicated in this thread:

http://answers.unity3d.com/questions/224296/android-export-dex-failed-error.html?sort=oldest

When I try the fix listed in this thread:

http://forum.unity3d.com/threads/88119-Could-not-reserve-enough-space-for-object-heap-RESOLVED

by creating a _JAVA_OPTIONS env var using a value of -Xmx512m the compile appears to work, but then errors when trying to sign the package, even though the correct passwords are in the publishing settings. Error below

arsigner: unable to read password: The handle is invalid
Enter Passphrase for keystore: Picked up _JAVA_OPTIONS: -Xmx512m

UnityEngine.Debug:LogError(Object)
PostProcessAndroidPlayer:SignAndroidPackage(String ) (at C:/BuildAgent/work/14194e8ce88cdf47/Editor/Mono/BuildPipeline/PostProcessAndroidPlayer.cs:949)
PostProcessAndroidPlayer:PostProcess(BuildTarget, String, String, String, String, String, String, BuildOptions) (at C:/BuildAgent/work/14194e8ce88cdf47/Editor/Mono/BuildPipeline/PostProcessAndroidPlayer.cs:460)
UnityEditor.HostView:OnGUI()

If I use the _JAVA_OPTIONS, do all parameters have to be picked up from the env var?
Is there another way of setting this java compiler setting in a Unity config file or something?

Thanks

I had this error and solved it by making sure that Unity has write permission to the ‘Plugins’ folder (make sure nothing inside is ‘read-only’). You might have to restart Unity.

Hope this works for you.