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?

Kyle V.
  • 4,452
  • 8
  • 42
  • 72
  • 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 Dec 18 '11 at 21:56
  • 2
    I'd keep it out of /Program Files/ honestly that space in the path is just evil. – Blundell Dec 19 '11 at 08:29
  • 5
    closing eclipse and then pressing yes worked for me, just had this problem :) – JRowan Nov 20 '14 at 05:35
  • Solution for me was closing my emulator which was still running... – Denny Nov 11 '16 at 09:02

25 Answers25

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.

  • 1
    I will try this as a last resort. – Kyle V. Dec 18 '11 at 22:55
  • I found that this approach could also be applied to updating the `android-sdk\extras\android\support` folder – Anna Lam Jun 18 '12 at 05: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 Sep 07 '12 at 02:41
  • Thanks, this worked for me as well (update 22.2.1) - what a ludacris solution. – Justin Jasmann Oct 08 '13 at 15:22
64

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.

Kyle V.
  • 4,452
  • 8
  • 42
  • 72
  • 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. – Jake Wilson Apr 19 '12 at 19:23
  • 1
    It saved me...I was trying for fewer times.Thanks for the ans – Dinesh Prajapati Aug 12 '12 at 05: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! – Nick Hartung Oct 14 '12 at 16:41
  • It's not just an Eclipse thing; I'm getting it in Visual Studio 2013 with Xamarin. – B. Clay Shannon Mar 27 '14 at 18:57
  • Could having Android Studio simultaneously open be causing such a problem? – B. Clay Shannon Mar 27 '14 at 19:02
  • After having this problem in VS2013 / Xamarin and restarting, trying to open the SDK manager just results in an err msg ("Command did not execute successfully due to an unexpected exception. Please check the output window for additional information"). Here are the "More Details": System.ComponentModel.Win32Exception (0x80004005): The system cannot find the file specified at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo) at System.Diagnostics.Process.Start() ... (etc.) – B. Clay Shannon Mar 27 '14 at 19:14
  • 3
    For me, just closing Android Studio and hitting "Yes" to continue the installation worked. – Jay K Jul 22 '14 at 14:22
  • one important thing to mention, you have to run the android.bat as administrator. – blueray Oct 21 '14 at 18:44
  • It's also wise to see if no adb or java process is running any more on a Windows system (maybe also Linux, but this I don't know). I had issues with this too... – GeertVc Oct 22 '14 at 17:45
  • http://stackoverflow.com/questions/8839255/failed-to-rename-directory-tools-to-temp-toolpackage-old01-in-c-android-sdk-win it's also working for same issue... – Naitik Nov 26 '14 at 13:31
  • Closing Eclipse fixed it for me – Christopher Masser Dec 02 '14 at 13:09
  • Hello, thanks so much for your answer. For some reason, I can't locate the file android.bat. I searched it in file explorer, but there aren't any results. What should I do? – Ruchir Baronia Nov 15 '15 at 00:27
  • I have the [LockHunter](http://lockhunter.com/) tool installed, which shows the process that locks the folder. Indeed, Eclipse is locking the folder. Just closed it and it worked. – MC Emperor Feb 03 '16 at 16:14
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.

Jason
  • 7,950
  • 9
  • 53
  • 65
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.

hamish
  • 1,019
  • 1
  • 11
  • 19
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...

Tharanga
  • 2,509
  • 1
  • 18
  • 17
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.

Nanne
  • 61,952
  • 16
  • 112
  • 157
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 ...

virtualone
  • 76
  • 3
3

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

Jon
  • 188
  • 2
  • 12
  • 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 Aug 27 '12 at 18:43
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.

Mauno Vähä
  • 9,340
  • 3
  • 26
  • 52
1

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

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

nothing
  • 76
  • 4
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.

Andro Selva
  • 51,960
  • 51
  • 189
  • 237
Tony
  • 1
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.

L. G.
  • 9,087
  • 7
  • 47
  • 73
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.

denispyr
  • 1,339
  • 3
  • 20
  • 32
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 :)

Ram Prakash Bhat
  • 1,213
  • 12
  • 20
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!!!

Dhruvam Gupta
  • 464
  • 5
  • 10
0

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

Miros
  • 470
  • 1
  • 3
  • 11
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

DJphy
  • 1,192
  • 13
  • 30
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.
Siddarth Kanted
  • 5,182
  • 1
  • 26
  • 19
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.

radiolondra
  • 223
  • 3
  • 9
0

In Ubuntu following solved issue for me

  1. cd [tools/directory/path]
  2. sudo ./android
Sekar
  • 71
  • 1
  • 6
0

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

mbwasi
  • 3,152
  • 2
  • 27
  • 35
0

I just stopped the emulator, and problem was solved.

Milad Moosavi
  • 1,450
  • 7
  • 19
0

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

VDALLCO
  • 153
  • 9
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.

Blundell
  • 69,653
  • 29
  • 191
  • 215
0

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

Timothy Lee Russell
  • 3,673
  • 1
  • 34
  • 42