Search Unity

'Invalid Characters in Path' when attempting to build to Android

Discussion in 'Editor & General Support' started by Umopepisdn, Jun 16, 2011.

  1. Umopepisdn

    Umopepisdn

    Joined:
    Mar 28, 2011
    Posts:
    7
    Hello,

    I've run into an issue building to Android from Windows 7 x64. I have tried reinstalling Unity and the Android SDK multiple times and the problem still persists.

    The behavior is that when building, Unity declares my path to the Android SDK invalid, clearing its preferences setting for the Android SDK path and asking me for a new one.

    As soon as I do this, the build process aborts with these exceptions:

    Code (csharp):
    1. Error building Player: ArgumentException: Illegal characters in path.
    2. UnityEditor.HostView:OnGUI()
    Code (csharp):
    1. Exception: Error building Player: ArgumentException: Illegal characters in path.
    2. UnityEditor.BuildPlayerWindow.BuildPlayerWithDefaultSettings (Boolean askForBuildLocation, BuildOptions forceOptions) (at C:/BuildAgent/work/6bc5f79e0a4296d6/Editor/Mono/BuildPlayerWindow.cs:341)
    3. UnityEditor.BuildPlayerWindow.GUIBuildButtons (Boolean enableBuildButton, Boolean enableBuildAndRunButton, Boolean canInstallInBuildFolder) (at C:/BuildAgent/work/6bc5f79e0a4296d6/Editor/Mono/BuildPlayerWindow.cs:942)
    4. UnityEditor.BuildPlayerWindow.ShowBuildTargetSettings () (at C:/BuildAgent/work/6bc5f79e0a4296d6/Editor/Mono/BuildPlayerWindow.cs:923)
    5. UnityEditor.BuildPlayerWindow.OnGUI () (at C:/BuildAgent/work/6bc5f79e0a4296d6/Editor/Mono/BuildPlayerWindow.cs:697)
    6. System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture)
    7. Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.


    Here's the excerpt from the log file:
    Code (csharp):
    1. Unloading 157 unused Assets to reduce memory usage. Loaded Objects now: 1268.
    2. System memory in use: 188.0 MB.
    3. Unloading 13 Unused Serialized files (Serialized files now loaded: 2 / Dirty serialized files: 2)
    4. Error building Player: ArgumentException: Illegal characters in path.
    5. UnityEditor.BuildPipeline:BuildPlayerInternalNoCheck(String[], String, BuildTarget, BuildOptions)
    6. UnityEditor.BuildPlayerWindow:BuildPlayerWithDefaultSettings(Boolean, BuildOptions) (at C:\BuildAgent\work\6bc5f79e0a4296d6\Editor\Mono\BuildPlayerWindow.cs:339)
    7. UnityEditor.BuildPlayerWindow:GUIBuildButtons(Boolean, Boolean, Boolean) (at C:\BuildAgent\work\6bc5f79e0a4296d6\Editor\Mono\BuildPlayerWindow.cs:942)
    8. UnityEditor.BuildPlayerWindow:ShowBuildTargetSettings() (at C:\BuildAgent\work\6bc5f79e0a4296d6\Editor\Mono\BuildPlayerWindow.cs:923)
    9. UnityEditor.BuildPlayerWindow:OnGUI() (at C:\BuildAgent\work\6bc5f79e0a4296d6\Editor\Mono\BuildPlayerWindow.cs:697)
    10. System.Reflection.MonoMethod:InternalInvoke(Object, Object[], Exception)
    11. System.Reflection.MonoMethod:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)
    12. System.Reflection.MethodBase:Invoke(Object, Object[])
    13. UnityEditor.HostView:Invoke(String, Object) (at C:\BuildAgent\work\6bc5f79e0a4296d6\Editor\Mono\GUI\DockArea.cs:213)
    14. UnityEditor.HostView:Invoke(String) (at C:\BuildAgent\work\6bc5f79e0a4296d6\Editor\Mono\GUI\DockArea.cs:206)
    15. UnityEditor.HostView:OnGUI() (at C:\BuildAgent\work\6bc5f79e0a4296d6\Editor\Mono\GUI\DockArea.cs:107)
    16.  
    17. [C:/BuildAgent/work/6bc5f79e0a4296d6/Editor/Src/Commands/BuildPlayerUtility.cpp line 1534]
    18. (Filename: C:/BuildAgent/work/6bc5f79e0a4296d6/Editor/Mono/BuildPlayerWindow.cs Line: 339)
    19.  
    20. - starting compile Library/ScriptAssemblies/Assembly-CSharp-firstpass.dll, for buildtarget 13
    21.  
    22. *** Cancelled 'Build.Player.AndroidPlayer' in 8 seconds
    23.  
    24. Exception: Error building Player: ArgumentException: Illegal characters in path.
    25.   at UnityEditor.BuildPlayerWindow.BuildPlayerWithDefaultSettings (Boolean askForBuildLocation, BuildOptions forceOptions) [0x001b1] in C:\BuildAgent\work\6bc5f79e0a4296d6\Editor\Mono\BuildPlayerWindow.cs:341
    26.  
    27.   at UnityEditor.BuildPlayerWindow.GUIBuildButtons (Boolean enableBuildButton, Boolean enableBuildAndRunButton, Boolean canInstallInBuildFolder) [0x0006d] in C:\BuildAgent\work\6bc5f79e0a4296d6\Editor\Mono\BuildPlayerWindow.cs:942
    28.  
    29.   at UnityEditor.BuildPlayerWindow.ShowBuildTargetSettings () [0x0054f] in C:\BuildAgent\work\6bc5f79e0a4296d6\Editor\Mono\BuildPlayerWindow.cs:923
    30.  
    31.   at UnityEditor.BuildPlayerWindow.OnGUI () [0x000f9] in C:\BuildAgent\work\6bc5f79e0a4296d6\Editor\Mono\BuildPlayerWindow.cs:697
    32.  
    33.   at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (object,object[],System.Exception)
    34.  
    35.   at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
    36. Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
    37.   at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
    38.  
    39.   at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <filename unknown>:0
    40.  
    41.   at UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) [0x0000f] in C:\BuildAgent\work\6bc5f79e0a4296d6\Editor\Mono\GUI\DockArea.cs:213
    42.  
    43.   at UnityEditor.HostView.Invoke (System.String methodName) [0x00000] in C:\BuildAgent\work\6bc5f79e0a4296d6\Editor\Mono\GUI\DockArea.cs:206
    44.  
    45.   at UnityEditor.HostView.OnGUI () [0x00058] in C:\BuildAgent\work\6bc5f79e0a4296d6\Editor\Mono\GUI\DockArea.cs:107
    46.  
    47. (Filename: C:/BuildAgent/work/6bc5f79e0a4296d6/Editor/Mono/BuildPlayerWindow.cs Line: 341)
    48.  
    49. - Finished compile Library/ScriptAssemblies/Assembly-CSharp-firstpass.dll
    50. - starting compile Library/ScriptAssemblies/Assembly-UnityScript.dll, for buildtarget 13
    51. - Finished compile Library/ScriptAssemblies/Assembly-UnityScript.dll
    52. Non platform assembly: data-0EFBD1D8 (this message is harmless)
    53. Non platform assembly: data-0F2DCF38 (this message is harmless)
    54. Platform assembly: C:\dev\Unity\Data\Mono\lib\mono\2.0\I18N.dll (this message is harmless)
    55. Platform assembly: C:\dev\Unity\Data\Mono\lib\mono\2.0\I18N.West.dll (this message is harmless)
    56. Mono: successfully reloaded assembly
    57. NullReferenceException: Object reference not set to an instance of an object
    58.   at UnityEditor.ListViewShared.HasMouseDown (UnityEditor.InternalListViewState ilvState, Rect r, Int32 button) [0x00000] in C:\BuildAgent\work\6bc5f79e0a4296d6\Editor\Mono\GUI\ListViewShared.cs:180
    59.  
    60.   at UnityEditor.ListViewShared.HasMouseDown (UnityEditor.InternalListViewState ilvState, Rect r) [0x00000] in C:\BuildAgent\work\6bc5f79e0a4296d6\Editor\Mono\GUI\ListViewShared.cs:175
    61.  
    62.   at UnityEditor.ListViewShared+ListViewElementsEnumerator.MoveNext () [0x0000c] in C:\BuildAgent\work\6bc5f79e0a4296d6\Editor\Mono\GUI\ListViewShared.cs:368
    63.  
    64.   at UnityEditor.ConsoleWindow.OnGUI () [0x00386] in C:\BuildAgent\work\6bc5f79e0a4296d6\Editor\Mono\ConsoleWindow.cs:422
    65.  
    66.   at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (object,object[],System.Exception)
    67.  
    68.   at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
    69.  
    70. (Filename: C:/BuildAgent/work/6bc5f79e0a4296d6/Editor/Mono/GUI/ListViewShared.cs Line: 180)
    71.  
    72. NullReferenceException: Object reference not set to an instance of an object
    73.   at UnityEditor.ListViewShared.HasMouseDown (UnityEditor.InternalListViewState ilvState, Rect r, Int32 button) [0x00000] in C:\BuildAgent\work\6bc5f79e0a4296d6\Editor\Mono\GUI\ListViewShared.cs:180
    74.  
    75.   at UnityEditor.ListViewShared.HasMouseDown (UnityEditor.InternalListViewState ilvState, Rect r) [0x00000] in C:\BuildAgent\work\6bc5f79e0a4296d6\Editor\Mono\GUI\ListViewShared.cs:175
    76.  
    77.   at UnityEditor.ListViewShared+ListViewElementsEnumerator.MoveNext () [0x0000c] in C:\BuildAgent\work\6bc5f79e0a4296d6\Editor\Mono\GUI\ListViewShared.cs:368
    78.  
    79.   at UnityEditor.ConsoleWindow.OnGUI () [0x00386] in C:\BuildAgent\work\6bc5f79e0a4296d6\Editor\Mono\ConsoleWindow.cs:422
    80.  
    81.   at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (object,object[],System.Exception)
    82.  
    83.   at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
    84.  
    85. (Filename: C:/BuildAgent/work/6bc5f79e0a4296d6/Editor/Mono/GUI/ListViewShared.cs Line: 180)
    86.  
    87. NullReferenceException: Object reference not set to an instance of an object
    88.   at UnityEditor.ListViewShared.HasMouseDown (UnityEditor.InternalListViewState ilvState, Rect r, Int32 button) [0x00000] in C:\BuildAgent\work\6bc5f79e0a4296d6\Editor\Mono\GUI\ListViewShared.cs:180
    89.  
    90.   at UnityEditor.ListViewShared.HasMouseDown (UnityEditor.InternalListViewState ilvState, Rect r) [0x00000] in C:\BuildAgent\work\6bc5f79e0a4296d6\Editor\Mono\GUI\ListViewShared.cs:175
    91.  
    92.   at UnityEditor.ListViewShared+ListViewElementsEnumerator.MoveNext () [0x0000c] in C:\BuildAgent\work\6bc5f79e0a4296d6\Editor\Mono\GUI\ListViewShared.cs:368
    93.  
    94.   at UnityEditor.ConsoleWindow.OnGUI () [0x00386] in C:\BuildAgent\work\6bc5f79e0a4296d6\Editor\Mono\ConsoleWindow.cs:422
    95.  
    96.   at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (object,object[],System.Exception)
    97.  
    98.   at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
    99.  
    100. (Filename: C:/BuildAgent/work/6bc5f79e0a4296d6/Editor/Mono/GUI/ListViewShared.cs Line: 180)
    101.  
    This issue only occurs when attempting to build to Android; I can build to standalone and web players without any problems, but it occurs on EVERY project, even one consisting of just the default scene. I have reinstalled Unity, scrubbing the registry of the entries I could find, as well as the Android SDK. I have also moved all of the paths around to avoid anything that could POSSIBLY be legitimately invalid -- for example, Unity and the Android SDK both live in C:\Dev\ instead of good old Program Files (x86), etc.

    As a side note, random (disturbing) exceptions appear intermittently throughout Unity. For example, double-clicking on an error in the console gives me this:
    Code (csharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. UnityEditor.ListViewShared.HasMouseDown (UnityEditor.InternalListViewState ilvState, Rect r, Int32 button) (at C:/BuildAgent/work/6bc5f79e0a4296d6/Editor/Mono/GUI/ListViewShared.cs:180)
    3. UnityEditor.ListViewShared.HasMouseDown (UnityEditor.InternalListViewState ilvState, Rect r) (at C:/BuildAgent/work/6bc5f79e0a4296d6/Editor/Mono/GUI/ListViewShared.cs:175)
    4. UnityEditor.ListViewShared+ListViewElementsEnumerator.MoveNext () (at C:/BuildAgent/work/6bc5f79e0a4296d6/Editor/Mono/GUI/ListViewShared.cs:368)
    5. UnityEditor.ConsoleWindow.OnGUI () (at C:/BuildAgent/work/6bc5f79e0a4296d6/Editor/Mono/ConsoleWindow.cs:422)
    6. System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture)
    So, it seems like something is seriously and fundamentally screwed with Unity on this computer.

    Please help -- I've uninstalled and reinstalled everything that seems directly relevant and I'm not sure what else to try. This is my main Unity dev system and so my next step is pretty much to reinstall Windows unless someone here has a suggestion, and I have no idea where the disc is. ;)

    Thanks,
    -Umo
     
  2. Umopepisdn

    Umopepisdn

    Joined:
    Mar 28, 2011
    Posts:
    7
    Also, if you're wondering, the Android SDK seems fine -- I can build and deploy Android projects from Eclipse without problems.
     
  3. Umopepisdn

    Umopepisdn

    Joined:
    Mar 28, 2011
    Posts:
    7
    Any ideas?
     
  4. Dwarf

    Dwarf

    Joined:
    Jun 21, 2011
    Posts:
    2
    The same issue.. Yesterday it was fine, but today I can not build any project for Android. Could it be a Unity software update or something got broken in the configs?
     
  5. Dwarf

    Dwarf

    Joined:
    Jun 21, 2011
    Posts:
    2
    Resolved.. It was crashing when trying to combine JAVA_HOME and 'bin'. Just removed quotes from JAVA_HOME environment variable value and it is fine now.
     
  6. Umopepisdn

    Umopepisdn

    Joined:
    Mar 28, 2011
    Posts:
    7
    Argh. I had tried adding quotes into the Java entry in my path, but not removing them from the JAVA_HOME. I'll try this tonight when I get home -- thanks!
     
  7. Umopepisdn

    Umopepisdn

    Joined:
    Mar 28, 2011
    Posts:
    7
    Confirmed resolved. Stupid JAVA_HOME. Stupid Microsoft for inflicting "Program Files (x86)" on us all. Stupid me for trying to be defensive with my environment variable definitions. Bah.
     
  8. nickfourtimes

    nickfourtimes

    Joined:
    Oct 13, 2010
    Posts:
    219
    Not to bump for no reason, but I've tried all of the path-renaming tricks above, to no avail. The log file still gives me the following:

    Code (csharp):
    1.  
    2. Error building Player: ArgumentException: Illegal characters in path.
    3.  
    4. (Filename:  Line: -1)
    5.  
    If the editor would have been kind enough to mention which file, that would have been handy, but alas...

    Using Unity 4.2.0f4
    Android SDK Tools rev 22.0.5
     
  9. nekete

    nekete

    Joined:
    Aug 27, 2010
    Posts:
    5
    I'm having the same problem but I don't have quotes.

    I don't get the general idea of the part "Resolved.. It was crashing when trying to combine JAVA_HOME and 'bin'. "

    Could any one put it into other words?.

    Thanks in advance and kind regards :)
     
    Last edited: Aug 31, 2013
  10. nickfourtimes

    nickfourtimes

    Joined:
    Oct 13, 2010
    Posts:
    219
    What was happening to them was that they had an environment variable called "JAVA_HOME" set to something like "C:\Java". When Unity builds the Android .apk, it tries to find some Java tools in the Java path, which it creates by appending "bin" to the value of JAVA_HOME. So, in the above case, it would look in the folder "C:\Javabin", which doesn't exist -- you have to set JAVA_HOME to something like "C:\Java\" with the trailing slash to make sure that Unity looks in the folder C:\Java\bin, which DOES exist (or should). So, everyone above was just making sure they had the trailing slash in their JAVA_HOME variables.

    I should note that these directories are different for just about everyone; also, adding the slash to my own environment variable didn't help, and I'm still having this problem.
     
  11. nekete

    nekete

    Joined:
    Aug 27, 2010
    Posts:
    5
    After reading other thread ( http://forum.unity3d.com/threads/192189-Unity3d-4-2-Invalid-Characters-in-Path ) I have tried other work around and It worked! :D.
    1-Download android sdk r21 : https://dl.google.com/android/android-sdk_r21-windows.zip
    2- Unzip in a different place than your usual android sdk.
    3- In android-sdk_r21, install the Android 4.0 SDK Platform (only)
    4- Select the android-sdk_r21 folder as android sdk in Unity
    5- Enjoy

    It seems to be some kind of problem with sdk r22. I hope it helps!.
     
  12. nickfourtimes

    nickfourtimes

    Joined:
    Oct 13, 2010
    Posts:
    219
    Wow, that worked like a charm. I'd tried variants on this approach before, but I must have gotten one or two steps wrong, previously. Thanks for laying it out so simply!
     
  13. badc0de

    badc0de

    Joined:
    Aug 9, 2012
    Posts:
    3
    Thanks, this fixed it for me too. 4.1 worked fine so this was really annoying, and the latest 4.2.1 still had the same problem.
     
  14. nekete

    nekete

    Joined:
    Aug 27, 2010
    Posts:
    5
    I'm glad to hear that :)
     
  15. SoloSebo

    SoloSebo

    Joined:
    Feb 28, 2013
    Posts:
    4

    Thank you so much! nekete! :) this worked for me.. now i just have to remember for next time !

    Take care and good luck on your projects
     
  16. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
  17. MoradGM

    MoradGM

    Joined:
    Jul 25, 2013
    Posts:
    14
    I don't want to bump this for no reason, but I was still having problems, even when I did everything anyone has ever suggested as a fix.
    I fixed it like this:
    JDK was in C:\Program Files (x86)\jdk*something*, so I copied the jdk folder to C:\, and went to my environment variables and changed the JAVA_HOME to C:\jdkfolder\ (the last slash is important), and it stopped showing the error ever since, even with the r22 sdk!

    Hope I helped.
     
    Last edited: Feb 22, 2014