Tom Magaro
Tom Magaro

Reputation: 167

Error The "ResolveLibraryProjectImports" task failed unexpectedly

I'm getting and error when trying to compile an Android project in VS2017 with Xamarin. I was getting a string type not allowed error and one of the suggestions was to update all my Xamarin.Android references. I found one that dealt with observables for the Xamarin.Core so I installed it. Every since then I have been getting the resolution error. I have tried deleting the obj and bin directories and restart vs and my laptop.

Here is the text for the error

Error       The "ResolveLibraryProjectImports" task failed unexpectedly.
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.
   at System.IO.PathHelper.GetFullPathName()
   at System.IO.Path.LegacyNormalizePath(String path, Boolean fullCheck, Int32 > maxPathLength, Boolean expandShortPaths)
   at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32   >maxPathLength, Boolean expandShortPaths)
   at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 >maxPathLength)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, >Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, >FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean >bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess >access, FileShare share)
   at System.IO.File.Open(String path, FileMode mode)
   at Xamarin.Tools.Zip.ZipEntry.DoExtract(IntPtr zipFile, String >destinationPath, FileMode outputFileMode, EntryExtractEventArgs args)
   at Xamarin.Tools.Zip.ZipEntry.Extract(String destinationDir, String >destinationFileName, FileMode outputFileMode)
   at Xamarin.Android.Tools.Files.ExtractAll(ZipArchive zip, String >destination, Action`2 progressCallback)
   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.ITaskExecutio>nHost.Execute()
   at >Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()    LayoutExample.Android       

Upvotes: 7

Views: 5109

Answers (5)

Gary Texmo
Gary Texmo

Reputation: 1

I was getting this when I added a reference to Xamarin.GooglePlayServices.Ads to my project via NuGet. As soon as I did this I got the same issue as the OP. Moving my code to the root directory of my C drive didn't help either, unfortunately; however, per Alper Ebicoglu's suggestion, I added...

<UseShortFileNames>True</UseShortFileNames>

... To my project file in the property group for my build configs. After I reloaded the project in Visual Studio, I was able to get my project to build.

Hope this helps!

Upvotes: 0

Valynk
Valynk

Reputation: 477

Had same problem. This is how I fixed it

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

Upvotes: 0

Alper Ebicoglu
Alper Ebicoglu

Reputation: 9614

the solution is edit your android project file (csproj) like below

enter image description here

https://github.com/xamarin/AndroidSupportComponents/issues/51

Upvotes: 3

Venkata Swamy Balaraju
Venkata Swamy Balaraju

Reputation: 1481

https://forums.xamarin.com/discussion/92979/error-the-resolvelibraryprojectimports-task-failed-unexpectedly

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

Upvotes: 4

DilbertDave
DilbertDave

Reputation: 3446

I've just answered this on another SO question (https://stackoverflow.com/a/44780549/31580).

The crux of it is that if your solution is saved to a location with a long path then this can cause some files to have a path which exceeds the maximum for Windows (260 characters)

Try moving the solution to the root of your C or D (if you have one).

Upvotes: 0

Related Questions