The "ResolveLibraryProjectImports" task failed unexpectedly
Asked Answered
G

25

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.

Gebhart answered 24/4, 2017 at 9:29 Comment(10)
What versions of Xamarin for Visual Studio, Xamarin.Android, and the Android SDK do you have installed?Hammers
xamarin is latest version, and i have all SDK versions downloadedGebhart
You can maybe try uninstall and installing the effected nuget packages, in this can RestSharpCaliph
restsharp is not from nuget. its a project that was already imported in this solutionGebhart
Is there a RestSharp.dll in the bin/Debug directory of your Android project after you build? If not then that's your problem.Hammers
You either install RestSharp via nuget or make sue that a dll exists in the location of the reference to ReshSharpCaliph
let me check i never checked it beforeGebhart
dll is also there already and its assembly reference is also added in projectGebhart
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 holeGebhart
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.Rectory
H
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.

Hyatt answered 27/6, 2017 at 12:40 Comment(3)
You should get a Nobel prize for this solution! Thank you.Kaden
I tried this also and it did not resolve my issue, but I did it anyway because it probably helps.Godforsaken
The problem is almost always delete bin & obj folders in all directories. Hit F5Famine
H
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.

Hammers answered 24/4, 2017 at 9:53 Comment(1)
i have tried this but i will try again by deleting and if it works i will accept this answerGebhart
E
11

edit your android project file (csproj) like below

enter image description here

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

Eindhoven answered 21/9, 2017 at 14:2 Comment(3)
This seems like the only proper solution. Worked great. Thank Alper. ... I only had to add the <UseShortFileNames> element.Accrue
yeah it's like a hidden feature :)Eindhoven
OMG! I have spent so much time with this issue... Thanks a lot!Lumpfish
U
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
Unsling answered 5/11, 2017 at 8:21 Comment(0)
M
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.

Menhaden answered 25/7, 2018 at 16:37 Comment(0)
G
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

Garrard answered 8/9, 2018 at 15:27 Comment(0)
L
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.

Latt answered 27/2, 2018 at 10:25 Comment(0)
W
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 .-.

Washing answered 6/4, 2018 at 21:47 Comment(0)
M
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.

Missus answered 11/6, 2018 at 10:9 Comment(0)
L
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

Lie answered 25/6, 2018 at 6:41 Comment(0)
M
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.

Mountaineer answered 25/7, 2018 at 16:6 Comment(0)
M
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.

Manchu answered 26/11, 2018 at 9:33 Comment(0)
A
1

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

Athodyd answered 4/1, 2019 at 14:15 Comment(0)
A
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.

Apollinaire answered 19/8, 2019 at 14:18 Comment(0)
H
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.

Handwork answered 4/2, 2021 at 11:53 Comment(0)
B
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).

Bluepoint answered 6/9, 2017 at 21:6 Comment(0)
A
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

Arcturus answered 7/9, 2017 at 6:6 Comment(0)
P
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

Phonic answered 13/11, 2017 at 11:17 Comment(0)
S
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

Soda answered 24/5, 2018 at 16:26 Comment(0)
B
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

Bakery answered 25/6, 2018 at 3:4 Comment(0)
S
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.

Sismondi answered 27/7, 2018 at 7:46 Comment(0)
V
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.

Vidrine answered 26/1, 2019 at 21:13 Comment(0)
S
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.

Schistosome answered 21/3, 2019 at 20:24 Comment(0)
C
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.

Cobden answered 11/6, 2019 at 23:0 Comment(0)
B
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.

Busload answered 4/12, 2019 at 11:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.