Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

Access to the path "C:.....temp\Staging_Area\res\values\strings.xml" is denied

Discussion in 'Editor & General Support' started by KringleHeim, Sep 26, 2016.

  1. KringleHeim

    KringleHeim

    Joined:
    Jan 20, 2014
    Posts:
    4
    I'm trying to build and run a very simple game on my mobile (htc 1) for the first time. The game builds fine as a windows game, but I get said UnauthorizedAccessException when trying to build for android (only build, without running it). It's specifically when building for the phone.

    The "game" is very simple, just containing a few sprites, colliders, main camera, a Canvas with a button... the usual simple stuff, without any scripts trying to access files outside of the game.

    I'm running as administrator, checked that the file in question isn't set as read only, USB debugging and "allow mock locations" is applied on the phone, I've tried turning of the firewall, closing visual studio and I've gone for a good old restart.

    Any ideas?

    edit: Further details:

    UnauthorizedAccessException: Access to the path "C:\Users\...\Temp\StagingArea\res\values\strings.xml" is denied.
    System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.IO/FileStream.cs:320)
    System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share)
    (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)
    System.Xml.XmlTextWriter..ctor (System.String filename, System.Text.Encoding encoding)
    UnityEditor.AndroidXmlDocument.SaveAs (System.String path)

    edit2: Furthermore, it works perfectly fine to run an app from AndroidStudio on my phone.

    Some other guys had this problem years ago, http://forum.unity3d.com/threads/android-build-unauthorized-access-exception.186640/ . The solution there required using the editor function to build the project, or perforce. I'm using neither.
     
    Last edited: Sep 26, 2016
  2. KringleHeim

    KringleHeim

    Joined:
    Jan 20, 2014
    Posts:
    4
    So it kinda fixed itself. I was messing around with trying to put the game folder directly in the unity directory, and then getting an error message stating I had to change the bundle identifier. I then switched back to the project in my documents, and all of the sudden got the very same error here. After changing that, it works on the phone! :eek: I'm at a total loss as to why it would work all of the sudden, just after fiddling around with saving the project in the unity folder.

    In fear of the problem arising again, further clearance or someone bumping the thread, I'll keep it up for a few days.