Reputation: 5149
I am brand new to Xamarin.Forms projects. I have created a project with VS2019 which has not been modified in any way, added a Pixel 2 Pie 9.0 - Api 28 emulator within the Android Device Manager. When I try to run the project on the android emulator, I am unable to run my app, with the following exception in my error list:
Error XARDF7004: System.ArgumentException: Illegal characters in path.
at System.Security.Permissions.FileIOPermission.EmulateFileIOPermissionChecks(String fullPath)
at System.Security.Permissions.FileIOPermission.QuickDemand(FileIOPermissionAccess access, String fullPath, Boolean checkForDuplicates, Boolean needFullPath)
at System.IO.Directory.Delete(String fullPath, String userPath, Boolean recursive, Boolean checkHost)
at Xamarin.Android.Tasks.RemoveDirFixed.RunTask()
at Xamarin.Android.Tasks.AndroidTask.Execute()
Since I am simply using a basic project template generated by VS2019, this has to be a bug on Microsofts end. How can I fix their error?
Upvotes: 6
Views: 5679
Reputation: 11
There is an another one you need to consider to resolve the System.Argument Exception having "An element with X already exists in NameScope". To solve this issue try to check if your code behind is having two InitializeComponent(); in the constructor.
Because, when the InitiallizeComponent(); is declared twice the system tries to Initialize the same components with the same name, so getting the exception "An element with X already exists in NameScope".
Upvotes: 0
Reputation: 361
I spent hours on this error and none of the suggestions regarding changing the path worked for me. What did work is I went into the android simulator and went into app settings and forced stop, as well as clearing storage and cache.
Upvotes: 0
Reputation: 1
A solution to this is the subst
command it creates a "new" drive at a folder location. Then you open the sln file from the new drive.
subst e: C:\Users\david\Dropbox\Projects\Visual Studio\PriceWatch\
then open the e: drive in file explorer or the open solution dialog
Upvotes: 0
Reputation: 101
I recently experienced this with VS 16.9.2 AND 16.9.3. And this is how I fixed it.
Open android SDK manager (make sure you have at least API level 29 or 30 checked).
Click on the Tools tab right next to Platforms Tab(that you will have landed on)
Ensure that the following are installed: -> ANDROID SDK command-line tools, Platform-tools, build tools, Android emulator and NDK
P.S. It might take a while to download and install. Don't forget to create your emulator of choice once the above steps have been successfully completed.
Upvotes: 1
Reputation: 12684
There are many causes for this error.
Mine was caused by having invalid directories in my system PATH. Removing the invalid entries and restarting my environment (either by killing and restarting all explorer.exe processes or by restarting machine) solved the problem.
Upvotes: 0
Reputation: 9763
Was able to fix this problem by starting an adb shell and go into the app directory:
/storage/emulated/0/Android/data/com.fips.SorterApp/files
then
rm -rf .__override__
and deploy worked again
Upvotes: 0
Reputation: 5149
It had to do with the character length of my solutions folder.
C:\Users\david\Dropbox\Projects\Visual Studio\PriceWatch\PriceWatch\PriceWatchXamarinForms\PriceWatchXamarinForms
(This bloated structure was generated by the IDE, everything after the Visual Studio folder)
I changed it to C:\Projects\PriceWatch\PriceWatchXamarinForms
and then it worked.
Upvotes: 15
Reputation: 89
I our case the reason was that some of our third party dependencies (api assemblies) forced us to set Properties > Android Options > Linking to "Sdk and User Assemblies" instead of "None".
Hope this helps someone... Bad error message.
Upvotes: 4