42
votes

I have just downloaded the Android SDK Command Line tools for Windows (26.0.2). I am attempting to download selected SDK components using \tools\bin\sdkmanager.bat, as well as updating \tools. The installation fails with the following message:

Warning: An error occurred during installation: Failed to move away or delete existing target file: C:\testinstall\sdk\tools Move it away manually and try again..

I don't see how I can remove \tools manually because it contains \bin\sdkmanager.bat.

Screenshot of the sdkmanager command:

enter image description here

All other components appear to install without error. See below for the components specified in my package file:

enter image description here

8
I don't see how your reference is relevant @Radhey?burntsugar
let me correct , you are trying to download sdk related stuff right !I thought stackoverflow.com/a/27060392/1848157 might be helpful .Radhey
@burntsugar You can directly download android studio with dependencies. The UI will give pretty good flexibility for modifications as well.Sreehari

8 Answers

66
votes

Yeah that's quite funny. A way to do that is to copy the tools folder to another place (let's say C:\temp\). Then direct into the C:\temp\tools\bin\, open the cmd prompt there and run your update commands as such:

sdkmanager.bat --sdk_root=sdkRootPath --command

Where sdkRootPath is path to your original SDK folder (C:\testinstall\sdk\). Once that is done, delete the C:\temp\tools\ copied folder.

6
votes

You could temporarily rename to tools.old, run it to install new version in tools and then remove the old one.

cd YOUR-ANDROID-SDK-LOCATION
ren tools tools.old
tools.old\bin\sdkmanager.bat "tools"
dir tools*
del tools.old /q /s
tools\bin\sdkmanager.bat --list
1
votes

it might be permission issue.Can you try doing sudo or if you on windows try to run terminal as administrator.

I have seen issues where the program is not able to delete the folder either due to lock or some weird reason.

1
votes

Run cmd in root c:.

c:\>testinstall\sdk\tools\bin\sdkmanager --package_file=c:\testinstall\packx.txt
1
votes

I've had the same issue on windows, I couldn't even rename the directory that is causing the issue.

I found out that adb was still running and ended the process and update/install worked fine without workarounds.

1
votes

The below command helped me to extract the SDK

sdkmanager "platform-tools" "platforms;android-28" --sdk_root=C:\AndroidSDK_RootLocation
0
votes

It may not be the answer to your question but now, i can't exactly remeber the version, you can't update SDK tools directly or using Eclipse, sdk Manager, sdk.bat or android.bat, only way is to update them using Android Studio. It's Google's new policy, i read it somewhere, if i find the link i will share it

0
votes

My solution was as following:

  1. Delete the Android SDK Tools via Android Studio (although it might complain it failed).
  2. Close Android Studio
  3. Manually delete tools folder from C:\Users\<MyUsername>\AppData\Local\Android\sdk folder
  4. Start Android Studio and then do the install of the Android SDK Tools via Android Studio.