New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aapt2 Task fails with Error Access to the path 'obj\Debug\monoandroid81\android\src' is denied. #1541

Closed
dellis1972 opened this Issue Apr 11, 2018 · 0 comments

Comments

Projects
None yet
1 participant
@dellis1972
Contributor

dellis1972 commented Apr 11, 2018

Occasionally on windows d15-7 we get the following error when running an android build.

Error        Access to the path 'obj\Debug\monoandroid81\android\src' is denied.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.Directory.InternalCreateDirectory(String fullPath, String path, Object dirSecurityObj, Boolean checkHost)
   at System.IO.Directory.InternalCreateDirectoryHelper(String path, Boolean checkHost)
   at System.IO.Directory.CreateDirectory(String path)
   at Xamarin.Android.Tasks.Aapt.GenerateCommandLineCommands(String ManifestFile, String currentAbi, String currentResourceOutputFile)
   at Xamarin.Android.Tasks.Aapt.ProcessManifest(ITaskItem manifestFile)
   at System.Threading.Tasks.Parallel.<>c__DisplayClass30_0`2.<ForEachWorker>b__0(Int32 i)
   at System.Threading.Tasks.Parallel.<>c__DisplayClass17_0`1.<ForWorker>b__1()
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.InnerInvokeWithArg(Task childTask)
   at System.Threading.Tasks.Task.<>c__DisplayClass176_0.<ExecuteSelfReplicating>b__0(Object )    MvvmCross.Droid.Support.Core.UI    C:\Program Files (x86)\Microsoft Visual Studio\Preview\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets    1325    
Error        One or more errors occurred.
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at System.Threading.Tasks.Task.Wait()
   at System.Threading.Tasks.Parallel.ForWorker<Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Func`4 bodyWithLocal, Func`1 localInit, Action`1 localFinally|TLocal>
   at System.Threading.Tasks.Parallel.ForEachWorker<TSource[] array, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Action`3 bodyWithStateAndIndex, Func`4 bodyWithStateAndLocal, Func`5 bodyWithEverything, Func`1 localInit, Action`1 localFinally|TSource,TLocal>
   at System.Threading.Tasks.Parallel.ForEachWorker<IEnumerable`1 source, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Action`3 bodyWithStateAndIndex, Func`4 bodyWithStateAndLocal, Func`5 bodyWithEverything, Func`1 localInit, Action`1 localFinally|TSource,TLocal>
   at System.Threading.Tasks.Parallel.ForEach<IEnumerable`1 source, ParallelOptions parallelOptions, Action`1 body|TSource>
   at Xamarin.Android.Tasks.Aapt.DoExecute()
   at Xamarin.Android.Tasks.Aapt.<Execute>b__138_0()
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()    MvvmCross.Droid.Support.V7.RecyclerView    C:\Program Files (x86)\Microsoft Visual Studio\Preview\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets    1325    

This is probably due to the working directory changing again.

VS bug #598515

@dellis1972 dellis1972 added this to the d15-7 milestone Apr 11, 2018

dellis1972 added a commit to dellis1972/xamarin-android that referenced this issue Apr 11, 2018

[Xamarin.Android.Build.Tasks] Use full path to create designer output…
… directory.

Fixes xamarin#1541

We missed one area in the changes where we worked around
the WorkingDirectory issues. We were not using the full path
to create the directory where the java R.java files are output.
As a result we ended up with the following error

	Error        Access to the path 'obj\Debug\monoandroid81\android\src' is denied.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.Directory.InternalCreateDirectory(String fullPath, String path, Object dirSecurityObj, Boolean checkHost)
   at System.IO.Directory.InternalCreateDirectoryHelper(String path, Boolean checkHost)
   at System.IO.Directory.CreateDirectory(String path)
   at Xamarin.Android.Tasks.Aapt.GenerateCommandLineCommands(String ManifestFile, String currentAbi, String currentResourceOutputFile)
   at Xamarin.Android.Tasks.Aapt.ProcessManifest(ITaskItem manifestFile)

Once again this is due to the working directory changing in the
thread that we are using.

So the solution is to use the full path to create the folder.
In theory because we use the `WorkingDirectory` on the process
we should NOT need to pass the full path as the command line
argument. While that might be a safer option we might well run into
issues were we exceed the max path or max command line length on
windows.

jonpryor added a commit that referenced this issue Apr 11, 2018

[Xamarin.Android.Build.Tasks] Use full path to create designer output…
… directory. (#1542)

Fixes: #1541

We missed one area in the changes where we worked around the
WorkingDirectory issues (45efffe): we were not using the full path
to create the directory where the java `R.java` files are output.
As a result we ended up with the following error:

	Error        Access to the path 'obj\Debug\monoandroid81\android\src' is denied.
	   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
	   at System.IO.Directory.InternalCreateDirectory(String fullPath, String path, Object dirSecurityObj, Boolean checkHost)
	   at System.IO.Directory.InternalCreateDirectoryHelper(String path, Boolean checkHost)
	   at System.IO.Directory.CreateDirectory(String path)
	   at Xamarin.Android.Tasks.Aapt.GenerateCommandLineCommands(String ManifestFile, String currentAbi, String currentResourceOutputFile)
	   at Xamarin.Android.Tasks.Aapt.ProcessManifest(ITaskItem manifestFile)

Once again this is due to the working directory changing in the
thread that we are using.

So the solution is to use the full path to create the folder. In
theory because we use the `WorkingDirectory` on the process we should
NOT need to pass the full path as the command line argument. While
that might be a safer option we might well run into issues were we
exceed the max path or max command line length on Windows.

jonpryor added a commit that referenced this issue Apr 11, 2018

[Xamarin.Android.Build.Tasks] Use full path to create designer output…
… directory. (#1542)

Fixes: #1541

We missed one area in the changes where we worked around the
WorkingDirectory issues (45efffe): we were not using the full path
to create the directory where the java `R.java` files are output.
As a result we ended up with the following error:

	Error        Access to the path 'obj\Debug\monoandroid81\android\src' is denied.
	   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
	   at System.IO.Directory.InternalCreateDirectory(String fullPath, String path, Object dirSecurityObj, Boolean checkHost)
	   at System.IO.Directory.InternalCreateDirectoryHelper(String path, Boolean checkHost)
	   at System.IO.Directory.CreateDirectory(String path)
	   at Xamarin.Android.Tasks.Aapt.GenerateCommandLineCommands(String ManifestFile, String currentAbi, String currentResourceOutputFile)
	   at Xamarin.Android.Tasks.Aapt.ProcessManifest(ITaskItem manifestFile)

Once again this is due to the working directory changing in the
thread that we are using.

So the solution is to use the full path to create the folder. In
theory because we use the `WorkingDirectory` on the process we should
NOT need to pass the full path as the command line argument. While
that might be a safer option we might well run into issues were we
exceed the max path or max command line length on Windows.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment