I am getting error cmdline-tools component is missing after installing Flutter and Android Studio... I added the Android SDK. How can I solve them?
The solution for me was opening Android Studio and going to SDK Manager, switch to the SDK Tools tab and check Android SDK Command-line Tools (latest).
Don't forget to add to your PATH the tools and platform-tools folder that are inside your SDK.
Failed to install the following Android SDK packages as some licences have not been accepted error
You need to accept the licences before building.
According to Android SDK docs you can use the following command depending on the sdkmanager location: Docs on --licenses
option seems to be missing though.
yes | sdkmanager --licenses
GNU/Linux Distributions:
yes | ~/Android/Sdk/tools/bin/sdkmanager --licenses
macOS:
export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jre/jdk/Contents/Home
yes | ~/Library/Android/sdk/tools/bin/sdkmanager --licenses
Windows:
%ANDROID_HOME%/tools/bin/sdkmanager --licenses
Flutter:
> flutter config --android-sdk 'path-of-android-sdk'(only for ubuntu user)
> flutter doctor --android-licenses
Android Command line tools sdkmanager always shows: Warning: Could not create settings
Instead of passing the argument --sdk_root
for each single command execution, let's deep dive into the real cause.
Starting from Android SDK Command-line Tools 1.0.0 (6200805), in contrast to Android SDK 26.1.1 (4333796), the tools
directory hierarchy has been changed.
Previously it was placed right inside ANDROID_HOME
(which is deprecated, we will use the term ANDROID_SDK_ROOT
for the rest of the paragraph), now it's still named as tools
(the only thing you'll get after unpacking the downloaded commandlinetools zip file), but differently, you have to place it inside a directory called cmdline-tools
on your own. The name cmdline-tools
comes from its package name, where you can get from listing packages command sdkmanager --list
, whose outputs include cmdline-tools;1.0 | 1.0 | Android SDK Command-line Tools
.
Wrapping tools
directory inside cmdline-tools
directory would make it work, and help you get rid of the annoying --sdk_root
argument. But what about the other parts?
Well, that's all you have to change. Let me explain more.
- The king -
sdkmanager
lives insidecmdline-tools/tools/bin
, you'd better set inPATH
environment variable cmdline-tools
should not be set asANDROID_SDK_ROOT
. Because later, when updating Android SDK, or installing more packages, the other packages will be placed underANDROID_SDK_ROOT
, but not undercmdline-tools
.- The final, complete
ANDROID_SDK_ROOT
directory structure should look like below, consist of quite a few sub-directories:build-tools
,cmdline-tools
,emulator
,licenses
,patcher
,platform-tools
,platforms
,system-images
. You can easily point out thatbuild-tools
andcmdline-tools
are siblings, all sit inside the parentANDROID_SDK_ROOT
.
Let me recap in a simple way:
- Set your preferred
ANDROID_SDK_ROOT
(just like before) - Download and unpack the commandlinetools zip file into a directory called
cmdline-tools
, which is insideANDROID_SDK_ROOT
- Append the directory
$ANDROID_SDK_ROOT/cmdline-tools/tools/bin
to environment variablePATH
, so that the system knows where to findsdkmanager
!!UPDATE!!
The behavior has changed again since the build 6858069
(Android SDK Command-line Tools 3.0):
- After unzipping the package, the top-most directory you'll get is
cmdline-tools
. - Rename the unpacked directory from
cmdline-tools
totools
, and place it under$ANDROID_SDK_ROOT/cmdline-tools
, so now it should look like:$ANDROID_SDK_ROOT/cmdline-tools/tools
. And inside it, you should have:NOTICE.txt bin lib source.properties
. Actually according to the official Command-Line Tools doc, the tree structure should beandroid_sdk/cmdline-tools/version/bin/
, but I've checked, usingversion
ortools
makes no difference here. - For your environment variable
PATH
, I would recommend you to set like this:PATH=$PATH:$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:$ANDROID_SDK_ROOT/cmdline-tools/tools/bin
, because after update later, you'll get the latestsdkmanager
placed under$ANDROID_SDK_ROOT/cmdline-tools/latest/bin
, put it in front will make it higher priority.
How to install old version of Android build tools from command line?
Assuming you have downloaded the Android SDK for linux, you have two options to update from command line.
Download using android tool from the sdk
Instead of running the android sdk manager with a GUI, you also have an option to run in headless mode. You just need to specify -u
(or --no-ui
) flag.
To list packages available for installation or upgrade:
$ cd android-sdk-linux
$ ./tools/android list sdk --all
Refresh Sources:
(...)
Fetching URL: https://dl.google.com/android/repository/repository-11.xml
(...)
Packages available for installation or update: 166
1- Android SDK Tools, revision 24.4.1
2- Android SDK Tools, revision 25.0.9 rc10
3- Android SDK Platform-tools, revision 23.1
4- Android SDK Platform-tools, revision 24 rc1
5- Android SDK Build-tools, revision 24 rc1
6- Android SDK Build-tools, revision 23.0.2
7- Android SDK Build-tools, revision 23.0.1
8- Android SDK Build-tools, revision 23 (Obsolete)
(...)
162- Google Play Billing Library, revision 5
163- Google Play Licensing Library, revision 2
164- Android Auto API Simulators, revision 1
165- Google Web Driver, revision 2
166- Intel x86 Emulator Accelerator (HAXM installer), revision 6.0.1
To download specific packages you need to specify the number of the item you want to install from the list in the following command:
$ ./tools/android update sdk -u -a -t [NO_OF_ITEM_TO_BE_INSTALLED]
Example: if I wanted to install Android SDK build tools revision 23.0.1, I would type in:
$ ./tools/android update sdk -u -a -t 7
Manual download
As not every package (especially the old ones) is listed when you do android sdk list
, you can also download things manually. You can manually open the XML file that is shown when during android sdk list
- https://dl.google.com/android/repository/repository-11.xml
You can find there links to various types of things to download, e.g:
- ADK
- http://dl.google.com/android/ADT-XX.0.0.zip
- SDK Tools
- http://dl.google.com/android/repository/tools_rXX-linux.zip
- http://dl.google.com/android/repository/tools_rXX-windows.zip
- http://dl.google.com/android/repository/tools_rXX-macosx.zip
- Platform Tools
- http://dl.google.com/android/repository/platform-tools_rXX-linux.zip
- http://dl.google.com/android/repository/platform-tools_rXX-windows.zip
- http://dl.google.com/android/repository/platform-tools_rXX-macosx.zip
- Build Tools
- http://dl.google.com/android/repository/build-tools_rXX-linux.zip
- http://dl.google.com/android/repository/build-tools_rXX-windows.zip
- http://dl.google.com/android/repository/build-tools_rXX-macosx.zip
- Platforms
- http://dl.google.com/android/repository/android-XX.zip
To manually download e.g. version 19.0.1 of build tools
$ cd android-sdk-linux/build-tools
$ wget http://dl.google.com/android/repository/build-tools_r19.0.1-linux.zip
$ unzip build-tools_r19.0.1-linux.zip
$ mv android-4.4.2 19.0.1
$ rm build-tools_r19.0.1-linux.zip
Side note (ubuntu):
If you're running debian/ubuntu 64-bit, to run aapt
you will need to install additional packages:
sudo apt-get install lib32stdc++6
sudo apt-get install lib32z1
If you're running CentOs (RedHat), to run aapt
you will need to install additional packages:
sudo yum install zlib.i686 libstd++.i686
While running aapt
, if you get an error with GLIBC 2.14 and you dont wont to upgrade your locale GLIBC. Then u need to download the following packages for sdk (build-tool, platform-tool) :
build-tool : http://dl.google.com/android/repository/build-tools_r23.0.2-linux.zip
platform-tool : https://dl.google.com/android/repository/platform-tools_r23.0.1-linux.zip
Related Topics
How to Make an Android App to Always Run in Background
Match_Parent Width Does Not Work in Recyclerview
Scan_Results_Available_Action Return Empty List in Android 6.0
How to Rotate the Android Emulator Display
Change Toolbar Color in Appcompat 21
How to Make an Imageview in Circular Shape
How to Read the File Content from the Internal Storage - Android App
Flinging with Recyclerview + Appbarlayout
How to Generate Class Diagram (Uml) on Android Studio (Intellij Idea)
How to Implement Filterable in Realmrecyclerviewadapter
Android Image View Pinch Zooming
Missing "<Sdk>/Extras/Google/Google_Play_Services/Libproject" Folder After Update to Revision 30
How to Use Custom Font with Webview
What's the Android Adb Shell "Dumpsys" Tool and What Are Its Benefits
Firebase (Fcm) How to Get Token