Android build failure to locate sdk error

Hi, I am trying to produce an Android build of a simple project using unity 4.0.1f2. but am unable to get past an error “Unable to locate the Android SDK installation folder”. The folder is set correctly in the preferences as c:\Users\user\Android\android-sdk. and the android installation is up to date and works with other eclipse android projects. However every time a launch a unity android build , a dialog prompt comes up with “Select Android SDK root folder” with a default location set to “C:\Program Files (x86)\android-sdk-windows” Note this is not the location of the sdk that is set in the preferences file but it always tries to set it to this. Trying to enter the correct location in this dialog always fails and reverts to this incorrect path. I have seen threads on this dating back over a year but no sensible answers to this other than to re-install everything.

Does anyone know an easier way to get the android build to work ?

I found the solution by opening the android studio
then File > Settings > Appearance & Behaviour > System Settings > Android SDK.
Copy the Android SDK location and paste it in Edit > Preferences > External Tools

found the solution in another thread here : http://forum.unity3d.com/threads/93303-Invalid-Characters-in-Path-when-attempting-to-build-to-Android

The problem occurs if you have JAVA_HOME set with quotes around the path, removing the quotes solved the problem for me. An error message that JAVA_HOME is not invalid would have been nicer behaviour though rather than this misleading dialog to reset the path of the SDK.