22

I'm trying to update Android Studio from 0.5.1 to 0.5.2 on two separate Windows machines, one with Windows 7 Pro 64-bit and one with Windows 7 Enterprise 64-bit.

I get the normal update prompt:

enter image description here

...and if I choose "Update and Restart", the patch downloads and the IDE exits, but then I get the following dialog:

enter image description here

I can't change any of the "Solution" column entries. If I click "Proceed", I get the following message as shown below (image and text, so its copy/paste/search-friendly):

enter image description here

Temp. directory: C:\Users\Sean\AppData\Local\Temp\

java.io.FileNotFoundException: C:\Program Files (x86)\Android\android-studio\lib\jsch.agentproxy.usocket-nc.jar (Access is denied)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:221)
at java.io.FileOutputStream.<init>(FileOutputStream.java:171)
at com.intellij.updater.Utils.copyStreamToFile(Utils.java:135)
at com.intellij.updater.CreateAction.doApply(CreateAction.java:52)
at com.intellij.updater.PatchAction.apply(PatchAction.java:140)
at com.intellij.updater.Patch$3.forEach(Patch.java:198)
at com.intellij.updater.Patch.forEach(Patch.java:248)
at com.intellij.updater.Patch.apply(Patch.java:194)
at com.intellij.updater.PatchFileCreator.apply(PatchFileCreator.java:86)
at com.intellij.updater.PatchFileCreator.apply(PatchFileCreator.java:77)
at com.intellij.updater.Runner.doInstallImpl(Runner.java:307)
at com.intellij.updater.Runner.doInstall(Runner.java:268)
at com.intellij.updater.Runner.access$000(Runner.java:18)
at com.intellij.updater.Runner$2.execute(Runner.java:258)
at com.intellij.updater.SwingUpdaterUI$7.run(SwingUpdaterUI.java:230)
at java.lang.Thread.run(Thread.java:744)

When I click "Exit", Android Studio re-opens, and tells me that the update is still available.

I've updated Android Studio previously using this same method on both machines without a problem.

Since I believe this is some kind of bug with Android Studio specific to newer releases, I've opened Issue 67794 on the AOSP issue tracker.

EDIT

I was able to update from 0.5.2 to 0.5.3 today on both machines without encountering this issue. I was shown the Windows security prompt for the JetBrains installer as in previous successful updates, and update completed successfully without me having to start Android Studio with elevated permissions. So, seems the problem was something specific to 0.5.1 or 0.5.2 patches.

EDIT

I encountered a similar error when trying to update from Android Studio 0.6.0 to 0.6.1:

Temp. directory: C:\Users\barbeau\AppData\Local\Temp\

+---------------- A file operation failed. This might be due to a file being locked by another application. Please try closing any application that uses the files being updated then press 'Retry'. +----------------

com.intellij.updater.RetryException: Cannot delete file C:\Program Files (x86)\Android\android-studio1\lib\openapi.jar at com.intellij.updater.BaseUpdateAction.replaceUpdated(BaseUpdateAction.java:40) at com.intellij.updater.UpdateZipAction.doApply(UpdateZipAction.java:199) at com.intellij.updater.PatchAction.apply(PatchAction.java:140) at com.intellij.updater.Patch$3.forEach(Patch.java:198) at com.intellij.updater.Patch.forEach(Patch.java:248) at com.intellij.updater.Patch.apply(Patch.java:194) at com.intellij.updater.PatchFileCreator.apply(PatchFileCreator.java:86) at com.intellij.updater.PatchFileCreator.apply(PatchFileCreator.java:77) at com.intellij.updater.Runner.doInstallImpl(Runner.java:307) at com.intellij.updater.Runner.doInstall(Runner.java:268) at com.intellij.updater.Runner.access$000(Runner.java:18) at com.intellij.updater.Runner$2.execute(Runner.java:258) at com.intellij.updater.SwingUpdaterUI$7.run(SwingUpdaterUI.java:230) at java.lang.Thread.run(Thread.java:745)

This seems to happen if you try to run the update while the Gradle build process is still running (e.g., right after you start up Android Studio).

Sean Barbeau
  • 11,496
  • 8
  • 58
  • 111
  • Try this link may help you. [Link here](http://stackoverflow.com/questions/16646646/how-can-i-switch-to-the-graphic-editor-in-android-studio) – altin bana Dec 25 '16 at 06:50

11 Answers11

27

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.

Sean Barbeau
  • 11,496
  • 8
  • 58
  • 111
  • 1
    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 Andriod studio that use such files will need elevated (Admin) access to work properly. – CJBS Aug 04 '14 at 21:54
  • @CJBS Have you encountered this issue? I haven't seen that problem yet on any of the machines I've been using. – Sean Barbeau Aug 04 '14 at 23:41
  • I've experienced it with the original Android installers - i.e. the Windows installers for initial installation (although not with the updaters). On one occasion, when I tried installing (or re-installing? -- can't remember) Android Studio as Admin, I had problems manually applying an update, due to permissions problems. I've also experienced it with other programs and add-ins (e.g. JetBrains Visual Studio plugins). Experiencing obscure problems related to file permissions later down the track can be ugly. (Also see, regarding permissions: http://stackoverflow.com/a/21033204/3063884) – CJBS Aug 04 '14 at 23:45
14

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.

Daniel Wilson
  • 18,838
  • 12
  • 85
  • 135
  • I hit this same problem in the 0.6.0 to 0.6.1 update. Mine resolved itself by letting the machine sit long enough (see update answer above), but this should also work. Seems there is some long running process that will end eventually, but blocks things in the normal update process timeline. – Sean Barbeau Jun 20 '14 at 14:14
  • 1
    From 0.8.0 to 0.8.2 I had the same problem. Running in administrator mode (I'm on Windows) and doing as you suggested, killing the larger Java process, fixed it and it updated. The larger one was about 800 for me, and the smaller one (the updater) was around 200. Killing the 800 did the trick. Thanks. – b85411 Aug 01 '14 at 05:35
  • it's helped me, when launched as admin mode worked for me – Abror Esonaliev Jan 13 '19 at 19:45
8

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.
CJBS
  • 15,147
  • 6
  • 86
  • 135
  • For me update from 1.4 to 1.5.1 was failing because the installer could not delete a file called providedRuntime-1.0.jar. This was a tiny file (553 bytes) buried deep inside temp directories named something like idea.updater.123456.... /gradle/..... etc. I used ProcessExplorer to kill all the java.exe instances - but I realized that the installer itself was a jave process so killing *all* java,exe instances would also kill the installer. I tried it by killing java.exe while Studio was running and then doing an Exit and Restart. I also noticed that the gradle build (3 min 18 s) was finished – pcomitz Dec 20 '15 at 14:43
4

You might also try to give your user permission to the folder.

  1. Right click the "android-studio" folder and select "Properties"
  2. Change to "Security" tab
  3. Click the "Edit" Button
  4. Select the group/user from the "Group or user names" list
    1. You can select/add your username to this list -or-
    2. Select the group "Users" (or the group where your user is)
  5. Select the "Full control" checkbox
  6. Click "Apply" and wait

You're done.

Telmo Marques
  • 5,066
  • 1
  • 24
  • 34
2

Disable antivirus and try update again.... Worked for me.

Sabeer
  • 3,940
  • 1
  • 24
  • 20
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. – Anirudh Sharma Aug 29 '15 at 14:18
  • OP asked the question in 2014 and he himself posted a workaround which fixed his issue. I posted the answer to others who came to this page by searching the issue. – Sabeer Aug 29 '15 at 15:52
2

I had a Java process running in the background on my Windows machine that wasn't showing up in my Task Manager. This will make sure Java gets killed:

taskkill /F /IM java.exe

Lou Morda
  • 5,078
  • 2
  • 44
  • 49
  • 1
    I had to run this command as administrator and precisely when Android Studio finished downloading but before it tried to apply the update. – tim.paetz Apr 21 '18 at 23:05
  • Yes definitely recommend opening Command Prompt as an Administrator – Lou Morda Apr 26 '18 at 23:44
0

I've stuck at the same issue, but I solved it by running this script in elevated console: Program Files\Android\android-studio\bin\update_studio.bat

Dmitry Weiner
  • 96
  • 1
  • 3
0

I solved a similar problem while updating Android Studio by just closing all other running applications, such as Firefox and restarted the update process.

It seems that a file is just by another program and it cannot be accessed by Android Studio.

Another way to solve this problem is to delete all files in the corresponding folder, such as: User/AppData/Local/Temp

stan
  • 229
  • 3
  • 10
0

I had the same problem - update from 0.6.0 to 0.6.1 After pressed button "Update", Android studio restarted and started to update. After this I got "Error message". I pressed "Retry" button - it was unsuccessful. Then I waited about 2 minutes (in my studio after start Gradle is working) and pressed again "Retry" - Done! :) Everything was updated. So in my case the reason of problem was Gradle that works after start of Android studio.

Iar0slav
  • 11
  • 1
  • 2
0

I had this same issue updating from 2.2 to 2.2.1. My solution was restarting Windows

gustavoknz
  • 482
  • 1
  • 6
  • 12
0

I used LockHunter to see what was locking the files. Result: Adb had locked some of them (I was testing the application by wifi in a mobile phone). I killed adb server, restart the Android Studio and I was able to update it.

Good luck for others!

J. Fdez
  • 156
  • 2
  • 5