Can't update Android Studio - Access Denied and java.io.FileNotFoundException

A workaround:

  1. Close Android Studio.
  2. Right-click "Android Studio" icon and select "Run as administrator".
  3. Go to "Help->Check for Update...", and go through the normal update process

I realized after a few failed update attempts from 0.5.1 to 0.5.2 that I was no longer getting the Windows security prompt to allow the JetBrains IntellJ installer to proceed, as I had seen in previous successful updates. I'm not sure what changed from previous updates, but apparently the update process was unsuccessfully trying to access files without proper permissions. Elevating Android Studio to admin through the above process fixed the issue.

As noted in the question above, this issue no longer seems to occur with the update from 0.5.2 to 0.5.3.

EDIT

To fix the next error I encountered with the Android 0.6.0 to Android 0.6.1 update, I shut down Studio and then restarted it, and let it sit overnight (more by coincidence than design). When I returned to the machine in the morning and ran the update, it succeeded. So, it seems there is some kind of long running process that blocks the update under certain conditions (likely immediately after startup - possibly the Gradle build process?). @Daniel Wilson's answer below should also work for this scenario.


This happened with me updating from 0.6.0 to 0.6.1. I had attempted to open AS in admin mode with every other application closed but the update still failed for me. I also tried deleting the Temp folder.

Eventually I noticed in the task manager when everything was closed I still had a sizeable java.exe still running in the background for some reason.

What I did was open AS in admin mode, run the update and let it fail, claiming a file is locked / access is denied or something similar. Open the task manager and I noticed 2 java.exe processes running. For me the smaller one (about 200k) was the AS updater utility itself. But if I killed the larger one (about 600k), and hit retry, the update went through without issue.


Don't re-install as an Administrator!

Whilst running in Admin mode might make the update work, it may also affect the permissions that are set on any files that are added and/or updated, such that future operations in Android studio that use such files will need elevated (Admin) access to work properly.

Doing this will result in many operations not working unless Android Studio has been run in elevated mode.

Instead, deal with the file lock, then try again:

Try killing all instances of java.exe (in Task Manager or Process Explorer), then re-attempt the update, but not running as Administrator.

Every time I've used Process Explorer (on Windows) to check which application has a lock on one of the files that's blocked an Android Studio update, it's always been Java.

What worked for me (on Windows):

  1. Download Process Explorer, and kill all instances of java.exe: in Process Explorer, sort by the Process column and find java.exe instances, press Del on the highlighted row. (On a side note, the file that's blocking the update, for example jsch.agentproxy.usocket-nc.jar, can be checked by pressing Ctl+F, and then entering the file name)
  2. If the update process doesn't automatically resume, kill it by dragging the target icon enter image description here to the update process' window - this locates it in Process Explorer's Process window - and then press Del to delete the process
  3. Re-run Android Studio (from start menu), and re-initiate update process.