问题
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:
All other components appear to install without error. See below for the components specified in my package file:
回答1:
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.
回答2:
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
回答3:
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.
回答4:
Run cmd in root c:.
c:\>testinstall\sdk\tools\bin\sdkmanager --package_file=c:\testinstall\packx.txt
回答5:
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
回答6:
My solution was as following:
- Delete the Android SDK Tools via Android Studio (although it might complain it failed).
- Close Android Studio
- Manually delete
tools
folder fromC:\Users\<MyUsername>\AppData\Local\Android\sdk
folder - Start Android Studio and then do the install of the Android SDK Tools via Android Studio.
回答7:
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.
来源:https://stackoverflow.com/questions/43796568/cant-update-tools-android-sdk-command-line-tools-for-windows