I want to setup the Android dev environment from command line, and encounter the following issue:
wget http://dl.google.com/android/android-sdk_r22.0.5-linux.tgz
after extract the file, run
tools/android update sdk --no-ui
However, it is too slow on running
Fetching https://dl-ssl.google.com/android/repository/addons_list-2.xml
The result is that nothing in folder build-tools, and I want is aapt and apkbuilder, since I want to build apk from command line without ant.
Download android SDK from developer.android.com (its currently a 149mb file for windows OS). It is worthy of note that android has removed the sdkmanager GUI but has a command line version of the sdkmanager in the bin folder which is located inside the tools folder.
I hope this helps. :)
Most of the answers seem to ignore the fact that you may need to run the update in a headless environment with no super user rights, which means the script has to answer all the
y/n
license prompts automatically.Here's the example that does the trick.
No matter how many prompts you get, all of those will be answered. This
while/sleep
loop looks like simulation of the yes command, and in fact it is, well almost. The problem withyes
is that it floods stdout with'y'
and there is virtually no delay between sending those characters and the version I had to deal with had no timeout option of any kind. It will "pollute" stdout and the script will fail complaining about incorrect input. The solution is to put a delay between sending'y'
to stdout, and that's exactly whatwhile/sleep
combo does.expect
is not available by default on some linux distros and I had no way to install it as part of my CI scripts, so had to use the most generic solution and nothing can be more generic than simple bash script, right?As a matter of fact, I blogged about it (NSBogan), check it out for more details here if you are interested.
Inspired from answers by @i4niac & @Aurélien Lambert, this is what i came up with
Explanation
android list sdk --all
command (Ignoring obsolete packages).As stated in other responses, the build tools requires the
--all
flag to be installed. You also better use a-t
filter flag to avoid installing ALL the packages but there is no way to filter all the build tools.There are already features requests for these two points in AOSP bug tracker. Feel free to vote for them, this might make them happen some day:
ADB Build-Tools Will Not be downloaded automatically, by command android update sdk --no-ui
So for installing Buil-Tool type (in console):
Remember the number that is listed before the item and execute the following:
commands should be typed in /YourFolder/android-sdk-linux/tools
Also for remote folder (server opened by ssh for example) type:
For simple list of ADB packages type in terminal:
for install all packages:
Or with filters (comma is separator):
Build tools could not be downloaded automatically by default as Nate said in https://stackoverflow.com/a/19416222/1104031 post.
But I wrote small tool that make everything for you
I used "expect" tool as danb in https://stackoverflow.com/a/17863931/1104031 post. You only need android-sdk and
python27
,expect
.This script will install all build tools, all sdks and everything you need for automated build: