42

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

burntsugar
  • 57,360
  • 21
  • 58
  • 81
  • refer http://stackoverflow.com/questions/17963508/how-to-install-android-sdk-build-tools-on-the-command-line – Radhey May 05 '17 at 05:01
  • 1
    I don't see how your reference is relevant @Radhey? – burntsugar May 05 '17 at 05:05
  • let me correct , you are trying to download sdk related stuff right !I thought http://stackoverflow.com/a/27060392/1848157 might be helpful . – Radhey May 05 '17 at 05:23
  • @burntsugar You can directly download android studio with dependencies. The UI will give pretty good flexibility for modifications as well. – Sreehari May 08 '17 at 14:24

8 Answers8

66

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.

ahasbini
  • 6,761
  • 2
  • 29
  • 45
  • 5
    Thank you, yes this worked. I reported an issue for this and was offered another solution which is basically the same thing. https://issuetracker.google.com/issues/38094997 "This is a known limitation of the current installation mechanism on windows" – burntsugar May 14 '17 at 22:48
  • 2
    Yeah I would definitely think so as in the previous versions of the sdk manager it was located at the root of the sdk folder, not inside the ```tools``` folder, hence there wasn't this issue of unable to delete, move or rename folders as much as we are facing with the new version right now. A design flaw that I hope will be delt with soon. – ahasbini May 14 '17 at 22:54
  • I get `access is denied` even though I have opened cmd as administrator – Snow Jan 21 '18 at 22:21
  • @JohnSmith could you post another question showing a screenshot of ur console and describing the steps you've taken and I'll be happy to help u there. – ahasbini Jan 21 '18 at 22:52
  • I was still having the problem with the update not being able to move/delete the tools folder. Turned out that Ihad a process, adb.exe from the Android SDK, which was running and had a lock on the tools folder, stopping other processes from doing anything with it. – SiBrit Jan 25 '18 at 04:39
  • Thanks @ahasbini I spent 1 and half day looking for its solution as there are not many articles directly referencing this particular type of issue. Thanks a lot. – Akshay Raut Apr 22 '18 at 10:56
6

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
Dan Dar3
  • 1,199
  • 13
  • 23
1

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.

rupesh jain
  • 3,410
  • 1
  • 14
  • 22
1

Run cmd in root c:.

c:\>testinstall\sdk\tools\bin\sdkmanager --package_file=c:\testinstall\packx.txt
Ahmad Aghazadeh
  • 16,571
  • 12
  • 101
  • 98
1

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.

Amr Osama
  • 78
  • 6
1

The below command helped me to extract the SDK

sdkmanager "platform-tools" "platforms;android-28" --sdk_root=C:\AndroidSDK_RootLocation
Mihail Duchev
  • 4,691
  • 10
  • 25
  • 32
Dipu Krishnan
  • 181
  • 1
  • 2
0

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

Thracian
  • 43,021
  • 16
  • 133
  • 222
0

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.
Nace
  • 2,854
  • 1
  • 15
  • 21
  • 1
    Please remove the first two lines as they add no value to your answer. –  Oct 14 '17 at 10:52