If you’ve seen this, you’ve probably been banging your head against the wall figuring out what it means. If you’re fairly sure there aren’t actual illegal characters in your project, then it’s likely about how long your path string becomes.
Error XARDF7004: System.ArgumentException: Illegal characters in path.
Assuming you’re using Visual Studio on Windows 10 when encountering this issue, it's likely related to
MAX_PATH which caps off at 260 characters on Windows due to compatibility.
At first I thought it might be related to spaces in folders, but that couldn’t be possible since my primary user on my machine has a space in it. In such an instance, every project would fail.
Then I thought maybe it was an invisible character in a folder name, so I copied my solution straight to C:\ and it worked.
Then I thought maybe it was related to length, so I started creating subfolders. I found that the project build would fail around 65 characters for path. That didn’t make any sense so I assumed it had to be something deep inside that exceeded some predetermined length.
Eventually, I was able to get this error to show up:
Error XA4209: Failed to create JavaTypeInfo for class: Android.Support.V4.View.Accessibility.AccessibilityManagerCompat/ITouchExplorationStateChangeListenerImplementor due to System.IO.PathTooLongException: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
This explicitly talks about 260 characters and 248 characters.
I continued researching and found this thread: https://developercommunity.visualstudio.com/content/problem/521034/failed-to-create-javatypeinfo.html#
So this is definitely related to the MAX_PATH problem on Windows. This will hopefully be solved with up coming changes in .net and MSBuild which will remove the MAX_PATH as a limit . This looks to be in d16 however it does require the user enable a setting on their machine via a Group Policy (see  for details).
After investigating that, it seems to be a pretty common issue:
The issue will be always present in Windows, to keep compatibility with old software. Use the NT-style name syntax "\?\D:\very long path" to workaround this issue.
To conclude, if you run into the
Illegal characters in path issue when compiling Android in Xamarin and you search for “xamarin system.argumentexception illegal characters in path”, I hope you find this article and realize it’s actually about how many subfolders you have your project nested in.