Bug 21719 - Access denied to a file on build
Summary: Access denied to a file on build
Status: RESOLVED FIXED
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: Android ()
Version: 3.0
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-07-30 19:11 UTC by Pete
Modified: 2017-05-12 18:13 UTC (History)
5 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Pete 2014-07-30 19:11:35 UTC
I'm using WaveEditor for a game, and everytime I try to build a project I get the following error:

Error	1	Unexpected error - Please file a bug report at http://bugzilla.xamarin.com. Reason: System.UnauthorizedAccessException: Access to the path "C:\Users\Pedro\Documents\Test\Test\LauncherAndroid\obj\Release\__library_projects__\WaveEngineAndroid.Adapter\native_library_imports\armeabi\libopenal32.so" is denied.	Launcher
Comment 1 Sunil Kumar 2014-07-31 06:29:14 UTC
Could you please provide us the test steps you followed. If possible please
attach a small complete project that demonstrates this behavior.

Also can you please add the logs from the following places?:
 
IDE log: Location: C:\User\AppData\Local\Xamarin\Log\ 
(Devenev file with latest timestamp)
Android Trace log: Location: \AppData\Local\Xamarin\Log\XamarinAndroid

This will help us efficiently confirm and fix this bug.
Comment 3 Pete 2014-07-31 14:35:55 UTC
Regarding the attached project, the steps to reproduce the bug are the following:

1) Install WaveEngine,
2) Download the nightly build for Android,
3) Go to C:\Program Files (x86)\Wave Engine\v1.0\Lib\Android,
4) Copy the unzipped files of the nightly build to that folder (repalce),
5) Open the provided test projects with VS 2012,
6) Compile the project in release mode.

Now, the first time you compile, deploy and run the project, everything goes well, and you will get the following warning:

Warning	1	Access to the path 'C:\Program Files (x86)\Wave Engine\v1.0\Lib\Android\DolbyAPI.dll.mdb' is denied.
   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)
   at Mono.CompilerServices.SymbolWriter.MonoSymbolWriter.WriteSymbolFile(Guid guid)
   at Pdb2Mdb.Converter.Convert(AssemblyDefinition assembly, IEnumerable`1 functions, MonoSymbolWriter mdb)
   at Pdb2Mdb.Converter.Convert(String filename)
   at Xamarin.Android.Tasks.CopyMdbFiles.Execute()	Launcher

7) Now, clean the project and, even though the output window says that it has been cleaned, on the Error Window you will get: 

Error	1	Access to the path 'libopenal32.so' is denied.	Launcher

8) From there try to compile and run the project (either by pressing the Start button or with F5), and you'll get:

Error	1	Unexpected error - Please file a bug report at http://bugzilla.xamarin.com. Reason: System.UnauthorizedAccessException: Access to the path "C:\Users\Pedro\Documents\Visual Studio 2012\Projects\TestProject\TestProject\LauncherAndroid\obj\Release\__library_projects__\WaveEngineAndroid.Adapter\native_library_imports\armeabi\libopenal32.so" is denied.	Launcher

Three importants notes:

1) Cleaning the project is a key factor here. The bug only happens after you clean the project,
2) The only way to build and deploy the solution again is by manually deleting both, the Bin and Obj folders of the Launcher project, and
3) There are no Xamarin logs generated when any of the error occur (cleaning or build fail).
Comment 4 Pete 2014-07-31 14:41:33 UTC
One final note: when you close VS2012 and try to manually delete the root folder of the solution (in my case "Test Project"), Windows Explorer says that you cannot delete it since another app or process is preventing it.

You can manually delete all the files and folders within it, but not the parent folder itself.
Comment 5 Sunil Kumar 2014-08-01 13:27:03 UTC
We have tried to reproduce this issue followed bu the steps given in comment 3 and we are also getting the same problem when we first time build the "Launcher" project then It shows the warning https://gist.github.com/sunil360/bf000f59364e0c847add and build the project second time then it shows error https://gist.github.com/sunil360/4b4db54b2aa8c0c3c7ab.

Screencast: http://screencast.com/t/QyVg21ZUIO
Warning : https://gist.github.com/sunil360/bf000f59364e0c847add
Error: https://gist.github.com/sunil360/4b4db54b2aa8c0c3c7ab

Environment info:
Microsoft Visual Studio Professional 2012
Version 11.0.61030.00 Update 4
Microsoft .NET Framework
Version 4.5.50938
Xamarin   3.1.228.0 (2349ba7b70529ea26ba842e1ec32d054bd6abb3b)

NOTE: We are getting same issue with XVS 3.3.46.0.
Comment 7 Pete 2014-08-05 14:11:36 UTC
Any news?
Comment 8 Pete 2014-08-14 16:24:21 UTC
Anyone?
Comment 9 Pete 2014-08-29 15:56:47 UTC
Any news on this bug?
Comment 10 Joaquin Jares 2015-10-06 16:31:54 UTC
This has been fixed recently and will be released in the next alpha updated. Marking as fixed for internal verification.
Comment 11 Buddhima Kudagama 2017-05-12 18:13:23 UTC
The reason for the error is there is a space in the path to the PROGUARD. Proguard is in the Android folder in Program Files (x86) and there is a spaces between "Program Files (x86)".

I solved it using a symbolic-link for the program files..

https://codezwithbuddhima.wordpress.com/2017/02/19/how-to-fix-error-cprogram-files-access-is-denied-when-proguard-has-enabled-while-build-a-android-app/