By zmbq


2011-12-19 10:03:14 8 Comments

I'm trying to upgrade the Android SDK tools from revision 15 to revision 16. The update fails, claiming that a "folder failed to be moved":

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

I tried disabling my antivirus (as this problem has been reported by some people in 2009), and it didn't work. A fresh reboot didn't work, either. I'm encountering this problem on two different Windows 7 machines.

I did not encounter this problem upgrading from previous revisions all the way up to revision 15.

Anybody knows how I can circumvent this?

15 comments

@radiolondra 2016-10-14 12:39:06

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.

@Androidcoder 2013-11-10 16:03:17

I tried all the various suggestions short of uninstalling and reinstalling the whole sdk and still got the error, including disabling thumbnails, which is the most common suggestion for folders you can't rename. I downloaded the free "processexplorer" from Microsoft to see what processes were using the folder, and after disabling all startup and non-Microsoft processes and finding no processes to be using the platform-tools folder, I still got the error, and found I couldn't rename it after the upgrade attempt.

The solution for me was to copy and paste the platform-tools folder found in the 'temp' folder in the android-sdk folder. Every upgrade I find a copy of the platform-tools in there, although for version 19 the platform-tools was zipped and the temp folder included versions of 18 and 17 which I left.

@pollifax 2013-07-13 19:25:30

To add to Subash's answer, if you have already attempted the upgrade, the tools zip file you need is in the android-sdk\temp folder.

@AVEbrahimi 2013-02-26 07:24:46

If none of above worked, try this:

  • Run task manager and close all java.exe instances.
  • Goto android-sdk-windows\temp and open tools_rXX.X-windows.zip ( replace X by latest version you've downloaded), now copy and replace it's content to tools folder.

@user946110 2012-02-17 01:43:16

First, you need to update ADT for your eclipse, my eclipse version is indigo

Then you can click "open android sdk manager" button to update your sdk to ver16

I have tried many method and this method help me to update it.

@user1015903 2012-08-29 07:42:46

It's very simple. Follow these steps:

  1. Download windows installer r_20sdk for android.
  2. To install it on your system run SDK.
  3. Install all packages.
  4. Go to eclipse, navigate to window - preference - click android.
  5. Give the path of your sdk click apply and ok now run you SDK manager.

Note: when you install sdk with the help of windows installer r_20SDK note the path or search the path in window search copy this.

@tyegah 2012-08-24 11:12:16

I think for those who still have the problem even if they already followed the answers here, try to see the processes in your system. Even if you close eclipse, sometimes it is still running in the background. So you can stop the process from the task manager.

@scottyab 2012-07-02 17:55:43

On Windows8, upgrading from SDKr19 to 20, I got the cannot move folder error. It's at least handled a bit by the SDK installer, with error message and chance to retry.

Right click cmd.exe, select Open as Administrator, cd to SDK directory (mine was default)

cd C:\Program Files\Android\android-sdk

Now run the SDK manager, except this time you'll be as Admin and it'll be able to move folders etc. So run it by typing:

"SDK Manager.exe"

Follow standard upgrade procedure

@Subash 2012-06-24 14:03:55

If you are unable to update Android SDK tools. Simply download the zip of android tools of version you want, and then replace the new tools directory with the old one. Then you are ready to go !!

@Steve 2012-06-23 18:23:39

Remove Platform tools folder and close eclipse that worked for me api17

@illo 2012-04-10 19:59:54

Replace android.bat with latest version (r18). It should be zipped in android-sdk/temp

Worked for me.

@SERPRO 2011-12-19 10:07:05

Extracted from here:

INSTRUCTIONS:

  1. make a copy of the tools directory and call this new directory tools2.
  2. DO NOT USE 'SDK Setup.exe'.
  3. Instead open up a cmd.exe window as administrator and run the following from this new tools2 directory (obviously the full path on your local machine will be different): J:\android-sdk-windows>tools2\android.bat update sdk

Basically, as noted before in this thread, 'SDK Setup.exe' invokes tools\android.bat, which makes it impossible for it to rename the tools directory thereafter. It's a bit goofy and should never have passed QA validation..

@zmbq 2011-12-19 12:25:24

How did I miss that? Thanks, I'll try it in a minute.

@zmbq 2011-12-19 12:27:29

Excellent! This worked! The Android team keeps unimpressing me, but there's nothing I can do about it.

@LarsH 2013-11-14 18:45:36

No doubt these instructions are successful in working around the problem, but I'm skeptical about the diagnosis of the cause. I had the same error message, and things started working fine for me after I opened up permissions on the sdk folder. Which means that invoking tools\android.bat was not the problem. Setups do vary over time, and maybe that was a problem at one point. But I would be reluctant to conclude that the developers made this particular goofy mistake that should never have passed QA.

@Dale Wilson 2014-08-15 22:32:33

@LarsH I got after installing Android Studio on a brand new machine following the instructions to the letter. I'd say "The developers made this particular goofy mistake." is an accurate statement. <humor> maybe it's an attempt to limit the number of Android developers to those who know about Stack Overflow </humor>

@Dina 2014-12-23 07:26:58

This didn't work for me. I think it has to do with the ANDROID_SWT environment variable. Instead, you can simply download the latest tools from developer.android.com/sdk/index.html (at the bottom there's a link for downloading the SDK tools only)

@Roel 2015-03-13 13:59:46

There is no android.bat in my tools directory...

@dd619 2015-04-21 06:58:25

Salute!!!..Thanks for serving the nation!

@ScottyC 2016-08-29 15:56:22

Just want to note, this solution also works on Unix (Linux and Mac OS X for page searchability) versions as well. Shell script is just called "android" with no extension. Thanks!

@not2qubit 2012-03-16 20:01:07

@SERPRO solution. Warning, this solution downloads ALL packages for all API (levels). It works, but it is very slow and perhaps worse than just backing up your folders and re-installing the SDK (all together). At least this is my experience for Windows Vista + Cygwin.

More than one bug-report have been issued. Here is one of the later ones, but it seem that it is never resolved. (It's already 2 years old.)

@SERPRO 2012-04-11 12:20:26

It will not download all packages.. you can select which one to install..

@not2qubit 2013-12-21 11:54:06

Well, as I said that's what happened to me, and there's no reason to down-vote someones findings for trying to help. I was doing it by Cygwin command line and THAT is what happened, period.

@KOsmix Fever 2012-01-22 18:08:58

Update SDK version using Eclipse (button Open the Android SDK Manager), running android.bat from a local copy of tools directory didn't work for me.

@Padma Kumar 2011-12-19 10:09:35

you need Eclipse 3.6 Helios or 3.7 Indico to upgrade your ADT revision 16.

It wont be upgrade in Eclipse 3.5 Galileo.

New: December 12, 2011 - SDK Tools and ADT 16 released.

NOTE: ADT 16 requires Eclipse 3.6 or higher.

http://developer.android.com/sdk/requirements.html

@zmbq 2011-12-19 12:25:04

I have Eclipse 3.7.

Related Questions

Sponsored Content

25 Answered Questions

[SOLVED] Is there a way to run Python on Android?

97 Answered Questions

30 Answered Questions

47 Answered Questions

[SOLVED] Is there a unique Android device ID?

28 Answered Questions

[SOLVED] What is 'Context' on Android?

77 Answered Questions

11 Answered Questions

[SOLVED] Proper use cases for Android UserManager.isUserAGoat()?

11 Answered Questions

[SOLVED] Android emulator doesn't take keyboard input - SDK tools rev 20

45 Answered Questions

[SOLVED] Android SDK installation doesn't find JDK

14 Answered Questions

[SOLVED] Failed to rename directory tools to temp\ToolPackage.old01 in C:\android-sdk-windows

  • 2012-01-12 17:14:20
  • Regex Rookie
  • 39029 View
  • 33 Score
  • 14 Answer
  • Tags:   android sdk

Sponsored Content