70

While trying to update my Android SDK I am encountering this error when trying to install this particular package:

enter image description here

How do I fix this?

4
  • 4
    Not sure, but move your SDK into c:\android-sdk\ Having it in \Program Files\ with that space in the directory is not going to help you. It will haunt you at every turn
    – Blundell
    Commented Dec 18, 2011 at 21:56
  • 2
    I'd keep it out of /Program Files/ honestly that space in the path is just evil.
    – Blundell
    Commented Dec 19, 2011 at 8:29
  • 5
    closing eclipse and then pressing yes worked for me, just had this problem :)
    – JRowan
    Commented Nov 20, 2014 at 5:35
  • Solution for me was closing my emulator which was still running...
    – Denny
    Commented Nov 11, 2016 at 9:02

25 Answers 25

95

This happens once in a while on my Windows SDK (even when I don't have any antivirus or similar programs running, execute the SDK-Manager as an administrator and so on).

I just update the tools by hand in this case. Which means close the SDK-Manager after the error and open the ANDROID_SDK\temp folder. There should be a zip named tools_R16.zip or similar (don't remember the exact name). Unzip that. You should end up with a tools folder. Copy all the files from this folder into ANDROID_SDK\tools. Overwrite when asked. And take a backup of the SDKs tools folder beforehand, just in case something explodes.

After that, start the SDK-Manager again. The tools version should be updated.

4
  • 1
    I will try this as a last resort.
    – Kyle V.
    Commented Dec 18, 2011 at 22:55
  • I found that this approach could also be applied to updating the android-sdk\extras\android\support folder
    – Anna Lam
    Commented Jun 18, 2012 at 5:51
  • 3
    This happened to me as well, so thanks for this answer. It is so damn frustrating, coming from XCode. Developing for Apple rocks. Developing for Android SUCKSSS. I just want to write some goddamn codes!!
    – GeneCode
    Commented Sep 7, 2012 at 2:41
  • Thanks, this worked for me as well (update 22.2.1) - what a ludacris solution. Commented Oct 8, 2013 at 15:22
63

The problem seems to be that Eclipse, or even the SDK Manager itself, locks the folder. Running android.bat from the tools folder should do the trick.

13
  • 3
    I'm pretty sure that having it in "Program Files" wasn't the problem. I experienced the same issue with my directory located at C:\Android`. Simply exiting Eclipse and then running C:\Android\tools\android.bat` fixed the problem for me. Commented Apr 19, 2012 at 19:23
  • 1
    It saved me...I was trying for fewer times.Thanks for the ans Commented Aug 12, 2012 at 5:20
  • 13
    It's worth noting that I needed to run android.bat as an admin or else I got the same error. Otherwise, works like a charm! Commented Oct 14, 2012 at 16:41
  • It's not just an Eclipse thing; I'm getting it in Visual Studio 2013 with Xamarin. Commented Mar 27, 2014 at 18:57
  • 3
    For me, just closing Android Studio and hitting "Yes" to continue the installation worked.
    – Jay K
    Commented Jul 22, 2014 at 14:22
37

If you launched the SDK Manager from Android Studio then all you need to do is close Android Studio.

I presumed the SDK Manager was a modal dialog that was part of Android Studio - not a separate program.

3
  • This worked for me. I closed Android Studio (which I had been running as admin) and clicked the retry button in the SDK manager, and it went right away. Commented Jul 26, 2014 at 15:08
  • worked for me as well.. I closed eclipse and it worked
    – kd0807
    Commented Sep 4, 2015 at 6:03
  • Wow, this is ingenious. This worked for me. Your prediction seems accurate.
    – Stardust
    Commented Jun 11, 2016 at 23:55
7

thanks. this is how I fixed it:

I updated the tools by hand in this case. Which means close the SDK-manager after the error and open the folder android-sdk-windows folder. Using LockHunter, unlock all programs from holding a lock on the android-sdk-windows\tools\ folder. http://lockhunter.com/?ver=&vertype=pro&sm=main_window_64

RENAME the android-sdk-windows\tools folder beforehand to tools_DELETEME There should be a zip named android-sdk-windows\temp\tools_r19-windows.zip. open that, You should see a tools folder in it. Copy that tools folder to android-sdk-windows\tools

After that, start the SDK-manager again. The tools version should be updated.

5

When you install tools/softwares use SDK manager. But don't use it when update. Do right click -> Run as administrator on android-sdk-windows\tools\android.bat file for updating tools. Always try to run commands as Administrator specially on Windows Vista/7/8. That'll fix most of permission issues etc...

4

You probably started the SDK manager from eclipse? I encoutnered the same problem, and fixed it by manually opening the SDK manager from the directy tools.

2
  • No I'm starting it from outside of Eclipse.
    – Kyle V.
    Commented Dec 18, 2011 at 22:54
  • Did you start it from the tools directory by using explorer, and is that window still open?
    – Nanne
    Commented Dec 19, 2011 at 12:37
3

My solution was to start it from within eclipse - as Administrator.

1
  • I wasted an hour or so trying to find and remove anti virus software and figure out what was locking the file only to remember windows 7 has that inferior run as administrator thing... what a pointless feature. But it worked for me despite being logged in as admin anyhow.
    – Kai Qing
    Commented Aug 27, 2012 at 18:43
3

well i had the same issue on windows 7 ... problem is that during the update it tries to rename the tools folder (inside the SDK folder) and that folder is used by a process "ADB" which is currently running ...

so you cannot do the update smoothly until you stop / kill that process ...

BTW copy pasting the new contents of tools folder from the temp would also work ...

1
  • Really Awesome trick.... Worked for me. Just killed adb process from Window Task Manager :) Commented Dec 12, 2014 at 10:02
2

With windows 7, when "failed to install popup" appears kill the process called adb (from task manager ctrl+alt+del) then press "Yes" and stuff is being installed.

1

I tried running android.bat and got the same error.

What worked for me was using unlocker to unlock the \tools folder.

1
  • You need to run android.bat as an administrator. That's why you got the same error.
    – Dzhuneyt
    Commented Feb 2, 2014 at 20:21
0

Ensure you don't have any essential files or folder opened/being used by other applications including explorer.

2
  • I did I even restarted my PC and made sure no processes or services were running that would do this.
    – Kyle V.
    Commented Dec 18, 2011 at 22:54
  • Explorer did it for me :P
    – jobbert
    Commented Jan 9, 2017 at 15:28
0

I've read before, people take a copy of the platform-tools folder and run the update from a different location. This ensures you haven't got open the files it's trying to update.

Could also disable your antivirus for 5 minutes o0o0.

1
  • I tried this and it didn't work either. Also, predictably, disabling antivirus did not help.
    – Kyle V.
    Commented Dec 18, 2011 at 22:52
0

On Windows 7 and probably Vista, run Eclipse as administrator.

0

My problem was Windows 7 security. I opened up the security on C:\Program Files\Android to EVERYONE with FULL access and it then worked. I then removed EVERYONE after the update was complete.

0

I had to make a copy of the tools folder itself (keeping it at the same directory tree level, thus "tools" and "tools-copy" were both in the "android-sdk-windows" folder). Then ran Android.bat from that copy.

After the update just delete the tools-copy folder.

0

The error message was Failed to rename directory C:\devtools\android-sdk\system-images\android-21\google_apis\x86 to C:\devtools\android-sdk\temp\SystemImagePackage.old01. I deleted the C:\devtools\android-sdk\temp\SystemImagePackage.old01 directory by hand (it was a leftover? I don't know) and it was able to proceed.

0

Same error i got while updating sdk. It is because of targeted folder locked (access permission is denied). You can resolve it as follows in "Ubuntu" :-

Press ALT + F2 and type 'gksudo nautilus' and navigate to the targeted folder like tools or extras and give create and delete permission. then update, every thing will be working fine :)

0

First make a copy of tools folder in same directory (android-sdk or android-sdk-windows) then delete the original tools folder and then open the android.bat file by double clicking in tools-copy folder to launch sdk manager and install the tools.

If tools folder is not being deleted then use the unlocker LockHunter to delete the folder and then open android.bat to update the tools.

After successful installation of tools delete the tools-copy folder.

Close Eclipse or Android Studio if open.

It worked for me!!!

0

On my PC it was caused by monitor.exe running in the background. Terminating that proces solved the problem.

0

Close the currently launched android studio window from task manager by going to the studioprocess (So when closed there are currently no active studio windows). Then go to Android studio in windows explorer, select the studio64/studio(if 32 bit OS) and right click and select run as administrator. In one line - you need to run Android Studio as a administrator. enter image description here

0

These are the steps followed by me.

  • Restart the computer.
  • Open "C:\android\androidStudio\sdk\tools\android.bat" as admin.
  • Now install packages should run fine.
0

I know this is an old post but I want to write my personal solution to the problem:

Failed to rename directory C:\android-sdk\tools to C:\android-sdk\temp\ToolPackage.old01.

Obviously I have had the same issue and every time the Android tools needs to be updated it's a nightmare.

None of the solutions I found googling the net worked for me up now, but this is a vital job to maintain Android SDK updated. So I started to find an alternative working way to solve this issue and I found it finally.... at least... it works for me, even if it is a bit tricky.

The basic problem is that the android.bat batch file comes from the ~\tools\ folder and it's still in memory (running) while the same ~\tools\ folder needs to be updated (in our case, renamed).

The problem is that the android.bat runs java to launch swt.jar (the SDK tool), and it remains uselessly waiting for completion of this java program.

You can edit the android.bat and see the call in the latest row of this batch:

call "%java_exe% %REMOTE_DEBUG%" "-Dcom.android.sdkmanager.toolsdir=%tools_dir%" "-Dcom.android.sdkmanager.workdir=%work_dir%" -classpath "%jar_path%;%swt_path%\swt.jar" com.android.sdkmanager.Main %*

The problem is the "call" CMD command. It waits for the called external program completion.

But ther's another way to run external programs from a batch file: the "start" command. It launches an external program and terminates.

So I just replaced the "call" command with "start", so that after the change the latest row of my android.bat was:

start "" "%java_exe% %REMOTE_DEBUG%" "-Dcom.android.sdkmanager.toolsdir=%tools_dir%" "-Dcom.android.sdkmanager.workdir=%work_dir%" -classpath "%jar_path%;%swt_path%\swt.jar" com.android.sdkmanager.Main %*

Note: Keep the "" in between start and the application path. You can add text in those hyphens and this text will be the caption of the java.exe command window you will see after the changes. In my case I left the caption as an empty string but you can write there what you want.

After the changes, you can start the SDK and the android.bat will be no more waiting, leaving the SDK tool free to play (and rename the ~\tools\ folder without headaches).

Obviously, after updating the SDK tools, you have to redo the same changes in the new, updated android.bat batch file. This could be a bit unconfortable, but you'll have just to remember to make the changes before running the SDK tool and you'll have no other headaches while updating Android.

0

In Ubuntu following solved issue for me

  1. cd [tools/directory/path]
  2. sudo ./android
0

Solved this on my side by killing the adb.exe in Task Manager.

0

I just stopped the emulator, and problem was solved.

Not the answer you're looking for? Browse other questions tagged or ask your own question.