I need to use the command line sdkmanager to update android tools. I must not use Android studio to do this.
However, if it works on Linux & Mac, it failed on Windows.
I received
"Warning: An error occurred during installation: Failed to move away or delete existing target file: C:\android-sdk\tools"
Why it doesn't work ?
Is there a way to perform this ?
See this other question: Can't update \tools - Android SDK Command Line Tools for Windows
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.
Related
I am trying to install Flutter without Android Studio and here is what I did:
Installed Java 8
Installed and Unzipped Flutter SDK to C:\src.
Installed and Unzipped Android Command-line tools (sdkmanager) to C:\Android.
Added the environment variables (ANDROID_HOME: C:\Android)
Now when I try to run sdkmanager to install Android SDK, I get this error:
"Error: Could not find or load main class com.android.sdklib.tool.sdkmanager.SdkManagerCli"
I have tried reinstalling Flutter sdk and the sdkmanager with no luck.
Here is Flutter Doctor's output:
sdkmanager error:
Open the sdkmanager.bat in a text editor and add echo %CLASSPATH% just below the CLASSPATH=%APP_HOME%\...\sdkmanager-classpath.jar. Then run sdkmanager --help which will echo the CLASSPATH of the required file. And check whether is it the valid path.
In my case, it was the wrong path,
It said my sdkmanger-classpath.jar is in lib folder. But it was not! It was actually inside the lib/_ folder. So as the simple solution what I did was copy the content in side lib/_ folder to lib. Then it worked fine!
Download the SDK tools ZIP (Under Command Line Tools in https://developer.android.com/studio).
Unzip using 7zip. Avoid using the default windows extractor - that doesn't do the extraction correctly.
After unzipping using 7zip, place the contents into the sdk folder (C:\Users\<username>\AppData\Local\Android\Sdk\tools\bin and C:\Users\<username>\AppData\Local\Android\Sdk\lib) and run sdkmanager on command prompt.
On Windows Server 2019, using commandlinetools-win-6609375_latest.zip, we faced the same issue. We placed package inside Program File (i.e. C:\Program Files\Android\cmdline-tools\tools\bin).
It seems this will not work if there is space in the path. So we placed it in folder path without spaces (i.e. C:\Android\cmdline-tools\tools\bin) and it is working fine!🎉
As #Chrishan wrote Avoid using default windows extractor.
You can use the PowerShell:
Expand-Archive commandlinetools....zip C:\Android\Sdk
It worked for me.
Make sure there exists no space in the path folders in the path to SDK.
example: C:\Users\Anu Jadav\xyz\
like above in username I had space, Initially, I was not able to execute flutter doctor --android-licenses.
After I renamed the username. Then it worked like a charm.
I renamed my username using this reference video
.
Go to android sdk folder.
Open cmdline-tools folder.
Then rename "latest" folder as "tools".
Default name:
(Path to sdk)\AndroidSDK\cmdline-tools\latest
After rename:
(Path to sdk)\AndroidSDK\cmdline-tools\tools
Then;
run flutter doctor command using terminal.
I fixed by adding '--sdkroot ' pointing to the root folder (i.e. parent of bin).
e.g. % ./bin/sdkamanager --sdkroot .
I have solved this issue by doing so many things.
Download Java 8.
Set EV to the Java 8 folder.
Download SDK in separate folder.
While setting EV of SDK make it sure there is no whitespace in the path.
Set path of the following in user variables:
Build-tools.
platform-tools.
platform
Now enter flutter doctor --android-licenses
press y multiple times and at last your licenses will be accepted.
Check whether your license accepted or not by using flutter doctor
Firstly open android studio and from there open sdk manager and install required sdk tools then -
Make sure there exist no space in the path folders in the path to sdk.
Add ANDROID_SDK_ROOT variable to the Users variable with value as the path for sdk folder e.g. C:\users\xyz\android\sdk (there should be no space in these folder names).
Add this path to the path variable in the system variable.
Run flutter doctor in the command prompt.
Run flutter doctor --android-licenses.
Accept the licenses by entering 'y'.
--The setup should be done and just check by running flutter doctor.
I fixed this issue by removing a space in my path where i had extracted the cmd tools.
My path was:
C:\Cordova Tools\cmdline-tools
there was a space in folder name "Cordova Tools".
I removed the space and changed folder name like:
C:\Cordova_Tools\cmdline-tools
And it worked just perfectly.
The problem may be due to the fact that your sdk installation failed severally before finally installing.
To check if that is the case, go the path C:\Users<username>\AppData\Local\Android\Sdk and if there are tools, tools-1, ...
The necessary files are installed in the last of this folder.
So, rename the supposed original folder - tools, to something else and change the name of the one in which the installation is done to tools.
This should solve the problem.
download jdk 11
and update ev JAVA_HOME to C:\Program Files\Java\jdk-11.0.17
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:
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.
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
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.
Run cmd in root c:.
c:\>testinstall\sdk\tools\bin\sdkmanager --package_file=c:\testinstall\packx.txt
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.
The below command helped me to extract the SDK
sdkmanager "platform-tools" "platforms;android-28" --sdk_root=C:\AndroidSDK_RootLocation
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
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 from C:\Users\<MyUsername>\AppData\Local\Android\sdk folder
Start Android Studio and then do the install of the Android SDK Tools via Android Studio.
What I'm attempting to do: Install the Android build tools on Mac OSX so I can use the aapt command to crunch/process some images for testing
What I've done:
Installed the Android SDK using brew
Run the android command to bring up the SDK Manager
Used the Manager to install the SDK tools (22.3), SDK Platform-tools(19), SDK Build-tools(19) and Android 4.4
I've verified that the tools were added to the default location when using brew.
What happens:
Running aapt or aapt v always returns Use the 'android' tool to install the "Android SDK Build-tools".
I've also tried updating the tools using android update, but it still fails to work.
EDIT:
Running the full path to aapt v works. I'm now assuming I have an issue with my PATH which I still need to resolve
Any clues as to what to try next would be greatly appreciated.
I'm pretty sure that the Android SDK doesn't try to modify your PATH variable for you. If you want to be able to run SDK tools without specifying their full path, you'll need to add the folder(s) containing them to your PATH one by one.
You can do this by editing your ~/.bash_profile and adding a line like so (or editing an existing line like this if you have one already):
export PATH="$PATH:/PATH/TO/android-sdk-macosx/build-tools/17.0.0"
Alternatively, you can just specify the full path to the tool when invoking it, like so:
/PATH/TO/android-sdk-macosx/build-tools/17.0.0/aapt v
I'm not sure this ever happens with aapt, but this can be useful to disambiguate if multiple versions of a tool are installed. To see which version of a command that bash is resolving to, you can usually find out by running which, like so:
which aapt
EDIT
There have been a number of good comments on this answer including Jared's excellent suggestion to dynamically add the latest build-tools to the path. I reimplemented his code in pure 3.x bash, here's what's currently in my ~/.bash_profile. First, make sure to set ANDROID_HOME:
export ANDROID_HOME="$HOME/Library/Android/sdk" #Set this to the path to your Android SDK if it's not in the default location
Then (if you are using bash):
BUILD_TOOLS=($ANDROID_HOME/build-tools/*)
ANDROID_LATEST_BUILD_TOOLS="${BUILD_TOOLS[#]:(-1)}"
export PATH="$PATH:$HOME/bin:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$ANDROID_LATEST_BUILD_TOOLS"
Alternatively, here is a POSIX version that should work in any shell:
ANDROID_LATEST_BUILD_TOOLS=$(ls -r ${ANDROID_HOME}/build-tools|head -1)
export PATH="$PATH:$HOME/bin:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$ANDROID_HOME/build-tools/$ANDROID_LATEST_BUILD_TOOLS"
I've created app with "phonegap create" command. Then I switch to project dir and try to run it with "phonegap local run android" and I have next error message:
Please install Android target 17 <...>
Android SDK is placed to C:\dev\sdk
My PATH variable contains C:\dev\sdk; C:\div\sdk\platforms\;C:\dev\sdk\platform-tools
I run "android" command from cmd and SDK Manager shows no updates or no missed sdk files.
I tried create and run project with cordova cli but had same problem.
What can it be?
It seems that for latest Cordova (3.0.6),
cordova platform add android
command only recognize Android 4.2.2(API17) SDK. After I install the API17 SDK, the error was gone.
Not sure if there is a cordova command option that can specify SDK version.
I had just the same problem (error message) with os x (10.8).
After executing the command android in the Terminal some android-packet-management-UI popped up. There i could install stuff that made it run ..
I had API17 installed but was still getting this error.
I needed to install apache-ant, set ANT_HOME=C:\Program Files\Java\apache-ant\, JAVA_HOME=C:\Program Files\Java\jdk1.7.0_21\ and add both bin's to my PATH += C:\Program Files\Java\jdk1.7.0_21\bin;C:\Program Files\Java\apache-ant\bin
See https://stackoverflow.com/a/13986997/956397
I had the same problem and the very most simple way to resolve it is changing the target in project.properties to 16 and try.
it seems if you type "android" at the same command prompt you type your cordova commands, you get a separate Android SDK manager then the one launched via Eclipse and so then there you select the appropriate packages and updates to achieve the version number of the Adroid SDK required. For me I'm guessing it's from an adt-bundle I installed with _? (I don't know actually no clue) that runs instead.
My best guess is the installer when updating doesn't doesn't update the path correctly.
Ya you need to manually correct duplicates and anomalies in the path.
Point to the "sdk" folder and tools of a valid most current adt-bundle-windows folder.
Maybe it was NetBeans that did this?
No it seems plausible when I put an update of Eclipse (C:\Library\Dev\Android\adt-bundle-windows-*) I must have not realized I needed to update the path too having done it manually the first time to get it to work.
It seems I needed plateform-tools added as well for adb to run the emulate command...
C:\Library\Dev\Android\adt-bundle-windows-x86_64-20131030\sdk;C:\Library\Dev\Android\adt-bundle-windows-x86_64-20131030\sdk\tools;C:\Library\Dev\Android\adt-bundle-windows-x86_64-20131030\sdk\platform-tools;
I have closed every window, restarted the computer. But Eclipse is telling me: "C:\Program Files\android-sdk\tools is being accessed....I even deleted the directory but I still get : how to fix?
Failed to rename directory C:\Program
Files\Android\android-sdk\platform-tools to C:\Program
Files\Android\android-sdk\temp\PlatformToolPackage.old01.
I have had this problem on Windows too. Instead of updating it through Eclipse, try the stand-alone option:
Close Eclipse
Open a Command Prompt window (ideally in
Administrator mode)
Run the command "android"
If you have the SDK tools directory in your path it will open the same UI you get in Eclipse but without additional file locking. If it is not in your path have a look in C:\Program Files\Android\android-sdk\tools and run "android.bat" from there.
Also, once you have updated the SDK, don't forget to fire up Eclipse and, on the Help menu, click "Check for Updates". You may well find the ADK Eclipse plugin needs to be updated too - this often goes in step with SDK updates.
Supposedly, if you use the SDK Manager.exe program rather than tools\android.bat, it works. However, I've never had any luck with that.
My traditional approach has been:
Duplicate the tools\ directory to create a foo\ directory
Adjust your PATH and other environment variables to point to foo\
Run the tools\android.bat out of foo\
Do the upgrade, which should work
When done, close out of the SDK and AVD Manager, revert your PATH and such to point back to tools\, and get rid of the foo\ directory
I'm guessing that adb is restarting with the computer. Try adb kill-server before upgrading
Another simple fix:
Close Eclipse. Open the directory where your SDK is located (C:\Users\user35\android-sdks) and run SDK Manager (as Administrator).