[FIXED] MSB401 The "ResolveLibraryProjectImports" task failed unexpectedly. System.IO.IOException

Issue

I have an XF solution that used to work flawlessly until last week.

This weekend I updated my VS2017 to the latest version i.e. v 15.9.24 and I started getting this compile-time error which says that my classes.jar is being used by another process. No other processes in my knowledge should be using it!!!

The previous version of Visual studio I had was v 15.9.12.

This happens only in the Android project rest seems to build just fine.

Any suggestions are welcomed.

Severity Code Description Project File Line Suppression State
Error The "ResolveLibraryProjectImports" task failed unexpectedly.
System.IO.IOException: The process cannot access the file ‘ProjPath\obj\Debug\90\lp\45\jl\bin\classes.jar’ because it is being used by another process.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
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, Int32 bufferSize)
at System.IO.File.OpenFile(String path, FileAccess access, SafeFileHandle& handle)
at System.IO.File.SetLastAccessTimeUtc(String path, DateTime lastAccessTimeUtc)
at Xamarin.Android.Tools.Files.ExtractAll(ZipArchive zip, String destination, Action2 progressCallback, Func2 modifyCallback, Func2 deleteCallback, Boolean forceUpdate) at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Extract(DirectoryAssemblyResolver res, ICollection1 jars, ICollection1 resolvedResourceDirectories, ICollection1 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.d__26.MoveNext() FoodSafety.Android

Output:

—— Rebuild All started: Project: FoodSafety.Android, Configuration: Debug Any CPU ——
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2110,5): warning MSB3277: Found conflicts between different versions of "Microsoft.CSharp" that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed.
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1327,2): error MSB4018: The "ResolveLibraryProjectImports" task failed unexpectedly.
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1327,2): error MSB4018: System.IO.IOException: The process cannot access the file ‘ProjPath\obj\Debug\90\lp\45\jl\bin\classes.jar’ because it is being used by another process.
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1327,2): error MSB4018: at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1327,2): error MSB4018: 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)
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1327,2): error MSB4018: at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1327,2): error MSB4018: at System.IO.File.OpenFile(String path, FileAccess access, SafeFileHandle& handle)
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1327,2): error MSB4018: at System.IO.File.SetLastAccessTimeUtc(String path, DateTime lastAccessTimeUtc)
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1327,2): error MSB4018: at Xamarin.Android.Tools.Files.ExtractAll(ZipArchive zip, String destination, Action2 progressCallback, Func2 modifyCallback, Func2 deleteCallback, Boolean forceUpdate) C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1327,2): error MSB4018: at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Extract(DirectoryAssemblyResolver res, ICollection1 jars, ICollection1 resolvedResourceDirectories, ICollection1 resolvedAssetDirectories, ICollection`1 resolvedEnvironments)
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1327,2): error MSB4018: at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Execute()
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1327,2): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1327,2): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext()
========== Rebuild All: 2 succeeded, 2 failed, 0 skipped ==========

UPDATE

Now it seems no matter what solution I open there is always this error in the Android project. Even if I create a new project :/

Solution

Well for those who are looking for a solution to this, Apparently it was caused not just by VS but also because of some incompatibility with my Xamarin.Build.Download package.

Updating it to 0.4.11 and updating my VS to latest solved it for me.

Answered By – FreakyAli

Answer Checked By – Senaida (Easybugfix Volunteer)

Leave a Reply

(*) Required, Your email will not be published