32

I have a Xamarin project, which is based on MvvmCross. The project is for both iOS and Android. I opened this project in Visual Studio 15. I got some errors, which I solved in no time. There are some errors, which are stuck and I couldn't solve them even after searching on Google and on Stackoverflow. I have tried each and every method found on Stackoverflow, but still all remaining errors are there. This project is using 3rd party libraries like RestSharp and BoxApi.V2 (few more)

I am posting my error log below.

Severity    Code    Description Project File    Line    Suppression State
Error       The "ResolveLibraryProjectImports" task failed unexpectedly.
System.IO.FileNotFoundException: Could not load assembly 'RestSharp(Android), Version=0.0.0.0, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'RestSharp(Android).dll'
   at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
   at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(String fullName, ReaderParameters parameters)
   at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(String fullName)
   at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.GetAssembly(String fileName)
   at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Extract(DirectoryAssemblyResolver res, ICollection`1 jars, ICollection`1 resolvedResourceDirectories, ICollection`1 resolvedAssetDirectories, ICollection`1 resolvedEnvironments)
   at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() BoxApi.V2 (Android)

This error is repeating for all projects included in this solution. So I am getting this error multiple times.

I also want to add that the project was previously built on MAC and I am using windows, does this make some compatibility or cross OS issue? I have checked all assembly references and all are working fine.

testing
  • 17,950
  • 38
  • 208
  • 373
Zaeem Sattar
  • 848
  • 2
  • 10
  • 27
  • What versions of Xamarin for Visual Studio, Xamarin.Android, and the Android SDK do you have installed? – Luke Pothier Apr 24 '17 at 09:45
  • xamarin is latest version, and i have all SDK versions downloaded – Zaeem Sattar Apr 24 '17 at 09:47
  • You can maybe try uninstall and installing the effected nuget packages, in this can RestSharp – Plac3Hold3r Apr 24 '17 at 10:33
  • restsharp is not from nuget. its a project that was already imported in this solution – Zaeem Sattar Apr 24 '17 at 10:44
  • Is there a `RestSharp.dll` in the `bin/Debug` directory of your Android project after you build? If not then that's your problem. – Luke Pothier Apr 24 '17 at 10:49
  • You either install RestSharp via nuget or make sue that a dll exists in the location of the reference to ReshSharp – Plac3Hold3r Apr 24 '17 at 10:54
  • let me check i never checked it before – Zaeem Sattar Apr 24 '17 at 10:55
  • dll is also there already and its assembly reference is also added in project – Zaeem Sattar Apr 24 '17 at 11:05
  • hey guys i found a weird thing in project. when i open my references folder i saw names of project names but when i open project there is no dll file in project because every project has dependent on other project and each project is missing other dll file. so its like a black hole – Zaeem Sattar Apr 24 '17 at 12:11
  • I had this same issue but it had nothing to do with paths. It's because I am trying to use .net standard instead of PCL since Microsoft is forcing us to. To resolve IServiceProvider not working I had to install system.ComponentModel v4.3.0 Installing system.ComponentModel v4.3.0 broke everything... had to uninstall it. Now I can run my app without error as long as I don't try to embed images. Has anyone found a resolution to this? I can't use embedded images in a .net standard without IServiceProvider and since Microsoft is killing off PCL we HAVE to move to .net standard. – Dan Nordquist Dec 23 '17 at 14:41

25 Answers25

39

I've literally just had this with a brand new Xamarin.Forms application in Visual Studio 2017.

The root cause appears to be that I let VS2017 create the project in it's default location 'C:\Users\Dave\Documents\Visual Studio 2017\Projects' and this has resulted in one of more files now having a path which it too long.

I moved the solution to the root of my D drive and it builds without any problem.

DilbertDave
  • 3,198
  • 3
  • 31
  • 40
11

Your issue is most likely linked to this post on the Xamarin forums, and this bugzilla entry. Without a reproducible sample, all I can advise you try is:

  • Updating Xamarin for Visual Studio, Xamarin.Android, and Xamarin.iOS to the latest stable versions
  • Cleaning and rebuilding
  • Deleting all of the bin and obj folders from your project directories
  • Restarting Visual Studio/your PC

Failing all of that, there's not likely to be anyone who can help you without a reproducible sample and potentially your Xamarin logs.

Luke Pothier
  • 942
  • 1
  • 6
  • 17
10

edit your android project file (csproj) like below

enter image description here

this issue topic may guide https://github.com/xamarin/AndroidSupportComponents/issues/51

Alper Ebicoglu
  • 6,488
  • 1
  • 34
  • 39
5

Had same problem. Here is my solution

  1. Restart Visual Studio
  2. Open the Project
  3. Clean the solution
  4. Rebuild the solution
  5. Close solution
  6. Reopen the project
Valynk
  • 414
  • 7
  • 6
2

I'm working with XAML (.xaml) and code-behind file (.xaml.cs). My issue was that I had the same page name, but under different namespaces. The XAML and the code behind file didn't match together. So finally it was an issue with my XAML, because of course it couldn't find the view element.

testing
  • 17,950
  • 38
  • 208
  • 373
2

Well for me the problem was in my xaml file...

Somehow while setting the Layout bounds i used '.' as a separator instead of ','

e.g

AbsoluteLayout.LayoutBounds="0.5.0.3,1,0.3" should have been AbsoluteLayout.LayoutBounds="0.5,0.3,1,0.3"

Hence changing the '.' to ',' solved the problem

kashalo
  • 3,072
  • 2
  • 9
  • 26
1

This happened to me when I accidentally installed nuget packages in a class library that was included in the solution. I just had to uninstall the packages from the class library project.

Michael Jedd
  • 44
  • 1
  • 7
1

In my case, this issue came with another related to my xaml.
I had to solved the second in order this error dissapear. I clean up the class with a new default content and then clean all projects and solution. By last, close visual studio, open it , run the project and It works know .-.

jan4co
  • 1,344
  • 1
  • 9
  • 13
1

This is still a fresh problem, after all attempts i wanted to try to shift the code to a shorter path - however that is lot of work as svn management will get complicated, so i wanted to first verify if path is really an issue, one way to do this was to check where the android SDKs are stored. I am on mac and the investigation revealed that SDKs path was longer than my project path. Plus i tried with a fresh project, and that was compiling correctly.

So i dropped the idea of shifting. Instead i used svn and compared what has changed since last correct build.

The comparison revealed that the project file of droid was somehow referring to the project file of iOS, it seems like some bug of Visual Studio. So i reverted the changes and than all got back to normal.

Kalpesh Popat
  • 811
  • 8
  • 10
1

i get the same error and i usually solve this by closing all other opened xamarin solutions and there is one more way i had solved this issue -> go to taskmanager and find MSBUILD Service and end that service -> clean your solution -> Rebuild

Ronak Shethia
  • 787
  • 4
  • 21
1

We have encountered this too, it appears to be some type of race condition when building multiple projects and a very deep/complex dependency tree (our example has over 100 projects).

The only way we've been able to resolve this (beyond continually rebuilding) is to disable Visual Studio 2017's Parallel Build Abilities (Tools->Options->Projects and Solutions->Build and Run->"1" Maximum number of parallel project builds).

The problem appears to be in ResolveLibraryProjectImports.cs (https://github.com/xamarin/xamarin-android/blob/93ddf96f86710ad848d5189858567dd7fe964579/src/Xamarin.Android.Build.Tasks/Tasks/ResolveLibraryProjectImports.cs) there is most likely a race condition with their logic to shorten up the file names.

There are zero tests around this which means there is most likely some dodgy code.

I am going to attempt to dig more and get an issue opened up on GitHub but finding a reliable repo is probably going to be very difficult.

aolszowka
  • 1,003
  • 11
  • 29
1

This worked for me:

  • Clean solution
  • Build one project at a time starting at the top - NOT rebuild solution - just one project at a time
  • Try deleting the contents of Obj and bin folder as well
  • When done delete the project from the emulator or device before you run it again

Hope this helps.

1

Still have issues ? Check your namespaces and your xaml code. Sometimes when you copy/paste some files, it can be the problem.

Alejandro Bastidas
  • 1,302
  • 2
  • 18
  • 25
1

Not sure if it will help anyone of you. For my case, I comment the erroneous class (eg. those with missing references), and it will start to pick up everything and build again.

hmheng
  • 55
  • 1
  • 8
1

In my case, I just forgot to delete the clicked event in XAML that doesn't exist in my code behind(cs file). After that, I just clean and rebuild.

I think that error was caused by not updated references.

Suraj Rao
  • 28,186
  • 10
  • 88
  • 94
Dyowed
  • 11
  • 1
0

It's probably an issue with your references / reference assemblies?

If you look under each project's references folder in the solution explorer, any references that visual studio cannot find, delete and re-add them (right click reference folder to add).

Kyle Burkett
  • 1,161
  • 11
  • 26
0

I have Faced this issue a thousand times its actually a very simple thing when you create a new project visual studio creates it in C:Drive in its default folder all you have to do is move your project out in some other Drive Like D:, E: whatever just make sure to keep it in the root of your Drive i.e. If you move it in D: Then place it like this D/Project/solutionFile

FreakyAli
  • 9,662
  • 3
  • 16
  • 45
0

Here is the problem: 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.

Try to move you project to another location like "C:/" , or change the name of the project for something more brief

Sumit Pathak
  • 472
  • 2
  • 7
  • 23
0

I encountered the same issue and none of the solutions above worked. After noticing and error on the list regarding Cryptography I knew it had to be related to FIPS being enabled (required by a VPN client)

Xamarin Compile Time Error

By disabling FIPS and restarting Visual Studio the issue was resolved.

enter image description here

Geovani Martinez
  • 1,821
  • 2
  • 24
  • 29
0

I had this error as well. In my situation it was accompanied by Xamarin.Forms.Maps not importing into the one of the xaml.g.cs files correctly. I had all the using statements correct. The IDE was showing no errors but it kept telling me that Xamarin.Forms did not have a name space Map. It was generating in MapPage.xaml.g.cs as Xamarin.Forms.Map instead of Xamarin.Forms.Maps.Map and I couldn't force a fix manually. It turned out though that the suggested xmlns:maps for maps was causing the problem. The IDE had told me to use "http://xamarin.com/schemas/2014/forms" but the correct namespace is "clr-namespace:Xamarin.Forms.Maps;assembly=Xamarin.Forms.Maps". After I changed this it was able to build my App1.dll

0

This was how I got the error. In a StackLayout I put in a Padding property, and I seperated the 4 digits by a space rather than a comma. To find the bug I had to comment out the XAML controls individually and rebuild to isolate where the error is, and eventually I found the problem line. So basically this was the error message I got for a syntax error in my XAML code! In any other language I would expect to be informed what the error is so I can fix it in seconds. But this took me a few hours - although next time I know what to do.

arame3333
  • 8,965
  • 19
  • 102
  • 191
0

This kind of issue may also come if by mistake you have any syntactical error like in my case: two text cells were present in the ListView -

<ListView x:Name="ProductsView">
    <ListView.ItemTemplate>
        <DataTemplate>
            <TextCell Text="{Binding ProductId}" />
            <TextCell Text="{Binding ProductDescription}" />
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>

I went through other posts for this issue and found the same issue occurred due to the presence of syntactical errors, which VS doesn't report directly. So look for this, otherwise, reinstall the compatible version of xamarin.forms -> clean solutions -> rebuild by reopening VS.

Kokul Jose
  • 714
  • 8
  • 23
0

I have faced the same problem today. After two days searching, I have found the solution here. The issue is Xamarin.Forms library does not install all its dependent Nuget packages while first creating project by choosing cross-platform Mobile(Xamarin.Forms) project template from Visual Studio 2017. I have to manually install the upgraded dependent nuget packages to build the project successfully. Also have removed and added Xamarin.Forms at the end which resolves the issue.

Also, it is some time creating issues when two instances of Visual Studio 2017 is running, make sure only one instance is only running as I have encountered this issue as well.

Subhajit Ray
  • 81
  • 1
  • 2
0
xmlns:maps="clr-namespace:Xamarin.Forms.Maps; assembly=Xamarin.Forms.Maps"

The problem was because of the space between the semicolon above and the assembly as stated above. As soon as the gap is closed, it compiles.

ItsPete
  • 2,323
  • 3
  • 26
  • 34
0

Shorteninig the path(folder names) to the solution solved it for me.

For example : the path was : C:\Users\Username\Downloads\Compressed\ListView-GettingStarted-in-Xamarin-Forms-master\ListView-GettingStarted-in-Xamarin-Forms-master\GettingStarted

and i changed it to : C:\Users\HelloKali\Downloads\Compressed\3\2\1.

Yashovardhan99
  • 690
  • 9
  • 23
Sh.Raai
  • 79
  • 9