Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Ubuntu 14.04 command line install android sdk
# install openjdk
sudo apt-get install openjdk-7-jdk
# download android sdk
wget http://dl.google.com/android/android-sdk_r24.2-linux.tgz
tar -xvf android-sdk_r24.2-linux.tgz
cd android-sdk-linux/tools
# install all sdk packages
./android update sdk --no-ui
# set path
vi ~/.zshrc << EOT
export PATH=${PATH}:$HOME/sdk/android-sdk-linux/platform-tools:$HOME/sdk/android-sdk-linux/tools:$HOME/sdk/android-sdk-linux/build-tools/22.0.1/
EOT
source ~/.zshrc
# adb
sudo apt-get install libc6:i386 libstdc++6:i386
# aapt
sudo apt-get install zlib1g:i386

Very usefull, thanks :)

Saved my day! Tnx!

Thanks!

thanx

dvrajan commented Mar 21, 2016

Thank you! Good one!

Thanks!!

rock and roll

Ou thank you greatly; This is very usefull

Thank you !

Thank you!

PierreGe commented Apr 24, 2016

It helped me speed up installation, thank you!

krestt commented Apr 27, 2016

I love you wenzhixin!!!

Thanks

Thank you sooo much :)

vdelacou commented May 2, 2016

Thank you

@ghost

ghost commented May 12, 2016

Thank you

uolcano commented May 17, 2016

thx

I was preparing this, thanks for saving my time :)

DUDE! Thank you!

sorry , I followed your instrction and now have a problem and it's that when I try to build my android app , I get the error below

Error: Please install Android target: "android-23".

Hint: Open the SDK manager by running: /home/hunter/Documents/android-sdk-linux/tools/android
You will require:

  1. "SDK Platform" for android-23
  2. "Android SDK Platform-tools (latest)
  3. "Android SDK Build-tools" (latest)

here is my sdk manager photo
http://i.stack.imgur.com/Ah216.png

please help me

At the line 18 gave me an error:
Vim: Warning: Input is not from a terminal
Vim: Error reading input, exiting...
Vim: preserving files...
Vim: Finished.
If any solution thank you a lot
-- Ubuntu 16.04

mitorski commented Jun 9, 2016

Confirm with @Yhochanan, dosen't work with 16.04.

qwertyI commented Jun 12, 2016

it's work for me!thx

THNX!!!

@Yhochanan I had the same error. I found that a vim swap file already existed and the file zshrc had some errors in it from a previous install. I deleted the swap file, then opened zshrc, fixed the errors and added the path.

-- Ubuntu 14.04

marty-Wallace commented Jul 4, 2016

This wouldn't work for me because it installed the android-sdk-linux directory in my home directory rather than in a directory named sdk. Created a directory named sdk and moved the android-sdk-linux directory into it and it worked like a charm afterwards.

Thanks.
--Ubuntu 15.10

kat0072 commented Jul 12, 2016

Thanks a lot.

Please add the Phablet tools setup as well those need to download the repo's and build source locally

sudo apt-get install phablet-tools

Thanks ! This was very useful !

cedxix commented Aug 9, 2016

Thank you !

yadejo commented Aug 18, 2016

Thanks!

thank you

useful! may be i can contribute for gentoo linux

shivasurya commented Sep 13, 2016

this is for Gentoo Linux Android SDK Command line installation guide https://gist.github.com/shivasurya/11aaf7d340bd37f9e501c59223a1febe

very helpful,
thanks

vg123 commented Sep 20, 2016

vi ~/.zshrc << EOT

export PATH=${PATH}:$HOME/sdk/android-sdk-linux/platform-tools:$HOME/sdk/android-sdk-linux/tools:$HOME/sdk/android-sdk-linux/build-tools/22.0.1/

EOT
Vim: Warning: Input is not from a terminal
Vim: Error reading input, exiting...
Vim: preserving files...
Vim: Finished.

please suggest any good solution for this error i need android studio urgently...

use nano editor.
nano ~/.zshrc
and put that line and save with ctrl+x

fidelis commented Sep 26, 2016

Very usefull, thak you indeed!

AstralisSomnium commented Sep 28, 2016

I use it for an environment without any userinput, so I get the exception:
Package not installed due to rejected license ''.

Before it asks y/n for accepting all licenses but my build machine just enters "", so how can I fix this?

SOLVED:

I got it working by replacing following line:
./android update sdk --no-ui
with:
echo "y" | ./android update sdk --no-ui

adibas03 commented Oct 4, 2016

L#11 has been updated to

./android update sdk -u

Qti3e commented Oct 13, 2016

Very useful, it saved my life!

zunjae commented Oct 18, 2016

thanks!!!

Came here to say thank you for sharing : )

Thanks bro...Very Useful.

Thank you dude, helpful!

thankz

Awesoem

but for Ubuntu 16.04 you need to do this first

sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get update
sudo apt-get install openjdk-7-jre

@TheBlackDude , here is the spellings of "Awesoem" > "Awesome"

If you getting E: Couldn't find any package by regex 'libstdc++6' and E: Unable to locate package zlib1g on last commands

$ sudo apt-get install libc6:i386 libstdc++6:i386
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package libc6
E: Unable to locate package libstdc++6
E: Couldn't find any package by regex 'libstdc++6'
$ sudo apt-get install zlib1g:i386
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package zlib1g

you can try

$ sudo dpkg --add-architecture i386
$ sudo apt-get update

and then repeat

# adb
sudo apt-get install libc6:i386 libstdc++6:i386
# aapt
sudo apt-get install zlib1g:i386

“vi ~/.zshrc << EOT

export PATH=${PATH}:$HOME/sdk/android-sdk-linux/platform-tools:$HOME/sdk/android-sdk-linux/tools:$HOME/sdk/android-sdk-linux/build-tools/22.0.1/

EOT”
this segment code just want to add environment variable permanent,we can use other way to complete it.
like this:

1.vi /etc/profile
2.add this command:
export PATH=${PATH}:$HOME/sdk/android-sdk-linux/platform-tools:$HOME/sdk/android-sdk-linux/tools:$HOME/sdk/android-sdk-linux/build-tools/22.0.1/
3.save it
4.open a new shell and type "echo $PATH"
5. check this works.

aakashhs commented Dec 4, 2016

Thanks a lot!!!

Thank you

dchrostowski commented Dec 9, 2016

This is the best piece of software on Github. I didn't have to go do things! This did all the things for me. +1000 internets for you. Also a nomination for the Nobel Peace Prize.

rmsouza commented Jan 14, 2017

thanks

*warning: * running android update sdk --no-ui will install everything. Check out this blog [1] for more instructions if you want a custom install.

[1] - http://sblackwell.com/blog/2014/06/installing-the-android-sdk-on-a-headless-server/

Great.Trying it.By the way is someone can help me to unbrick my htc one sv 4G LTE;Hardbrick due to bad flashing.Thanks in advance

Great.Trying it.By the way is someone can help me to unbrick my htc one sv 4G LTE;Hardbrick due to bad flashing.Thanks in advance.Bootloader locked but S-off

gougoudinho commented Feb 16, 2017

Please i have an error when i reach EOT.I am on ubuntu 12.04.Can i have help?Thanks

🚀

zukinaru commented Mar 9, 2017

Many Thanks :)

vsxen commented Mar 10, 2017

sometimes you may need run export ANDROID_HOME=${HOME}/android-sdk-linux/

Thanks a lot for this

many thanks! o/

Merci beaucoup ^^

terima kasih hehe

Hi,
Below error pops up when executing this command.

./android update sdk --no-ui

Exception in thread "main" java.lang.NullPointerException
at java.io.File.(File.java:277)
at com.android.sdklib.internal.avd.AvdManager.parseAvdInfo(AvdManager.java:1616)
at com.android.sdklib.internal.avd.AvdManager.buildAvdList(AvdManager.java:1577)
at com.android.sdklib.internal.avd.AvdManager.(AvdManager.java:350)
at com.android.sdklib.internal.avd.AvdManager.getInstance(AvdManager.java:373)
at com.android.sdklib.internal.repository.updater.UpdaterData.initSdk(UpdaterData.java:254)
at com.android.sdklib.internal.repository.updater.UpdaterData.(UpdaterData.java:122)
at com.android.sdklib.internal.repository.updater.SdkUpdaterNoWindow.(SdkUpdaterNoWindow.java:76)
at com.android.sdkmanager.Main.updateSdkNoUI(Main.java:497)
at com.android.sdkmanager.Main.doAction(Main.java:366)
at com.android.sdkmanager.Main.run(Main.java:150)
at com.android.sdkmanager.Main.main(Main.java:116)

thanks

it works, thanks a lot.

very usefull, thanks!!!

SirmaXX commented Jun 17, 2017

you are man of the material

would be awesome if you could merge my Fork :)
https://gist.github.com/Gnarmagon/1364394a9e4a88420a28b4db528392f3

(it copies the tar from everywhere into $HOME)

boga01 commented Jun 29, 2017

so helpful

mukana-lahtelat commented Jul 21, 2017

Do notice that this script assumes you're using ZSH, not bash. Replace .zshrc with .bashrc to fix

amazing.saved my day.thanks a lot

Jullies commented Oct 3, 2017

Thank You

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment