Skip to content

Instantly share code, notes, and snippets.

@venkateshshukla
Last active September 19, 2023 04:20
Show Gist options
  • Save venkateshshukla/9736261 to your computer and use it in GitHub Desktop.
Save venkateshshukla/9736261 to your computer and use it in GitHub Desktop.
Setting up your Linux for Android Application Development
Step 1. Preparation
--------------------
First take care of the dependencies for Android Application Development.
Dependencies are -
1. Java
2. ant
3. Eclipse and Android Development tools (IDE)
4. Android SDK and NDK
5. adb
1. Java
For Ubuntu visit the following site for easiest way of installing Java
http://www.webupd8.org/2012/01/install-oracle-java-jdk-7-in-ubuntu-via.html
For Fedora, the following link gives step by step instructions.
http://www.if-not-true-then-false.com/2010/install-sun-oracle-java-jdk-jre-7-on-fedora-centos-red-hat-rhel/
Make sure JAVA_HOME environment variable is set and added to path.
For linux systems, add the following lines to ~/.bashrc file
export JAVA_HOME=/usr/java/jdk1.7.0_51/bin
export PATH=$PATH:$JAVA_HOME
2. ant
For ubuntu - sudo apt-get install ant
For fedora - su -c 'yum install ant'
3. Eclipse and Android Development Tools
If you are willing to use and IDE, google recommends Eclipse.
If you wish to do development using just the terminal and text-editor this
step is not required. Skip it.
For detailed instructions on setting up Eclipse for android application
development visit
http://developer.android.com/sdk/installing/installing-adt.html
In short, the steps are -
1. Download eclipse
2. Install Android Development Tools either from an archive or remote repo
3. Restart
4. Android SDK and NDK
SDK - Software Development Kit
a. Download android sdk tools from
http://developer.android.com/sdk/index.html
b. Extract it to a directory say android_sdk
c. Set the environment variable ANDROID_SDK_ROOT to point to android_sdk
d. Add the directories android_sdk/tools and android_sdk/platform-tools
to your path
NDK - Native Development Kit
a. Download android ndk tools from
http://developer.android.com/tools/sdk/ndk/index.html
b. Extract is to a directory say android_ndk
c. Set the environment variable ANDROID_NDK_ROOT to point to android_ndk
d. Add the directories android_ndk to your path
For linux systems the environment and path can be set by adding the
following lines to ~/.bashrc file
export ANDROID_SDK_ROOT=/path/to/android_sdk
export ANDROID_NDK_ROOT=/path/to/android_ndk
export PATH=$PATH:$ANDROID_SDK_ROOT/platform-tools
export PATH=$PATH:$ANDROID_SDK_ROOT/tools
export PATH=$PATH:$ANDROID_NDK
5. adb
If the step 4 is completed, the path would contain adb as well.
To check, run adb command in terminal. If command not found
error is received, try restarting. Check if adb is present in
android_sdk/platform-tools
Step 2 : Check out eclipse and make your first application.
-------------------------------------------------------------
Launch eclipse. Go to File >> New >> New Project >> Android Application Project
Give suitable name and icon. Chose default view and navigation. A default
hello world application is made. Start android application development.
A valuable resource will be https://d.android.com.
Step 3 : Running adb.
-----------------------
Adb or Android Debug Bridge is located in android-sdk-linux/platform-tools/adb
But it rarely works correctly if you are setting everything up for the first
time.
The first issue that comes up is that adb is not recognized by the system.
On executing ./adb the following errors are encountered
Ubuntu Error: No such file or directory
Fedora Error: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory
The reason behind this is that adb included with the other tools in the
ADT Bundle or SDK Tools, is 32 bit and most probably the system you are
working on is 64 Bit. To remedy this, run the following command in the terminal.
for Ubuntu 12.04 and 12.10 sudo apt-get install ia32-libs
for Ubuntu 13.10 and beyond sudo apt-get install lib32z1 lib32ncurses5\
libstdc++6:i386
for Fedora su -c 'yum install libstdc++.i686\
ncurses-libs.i686 zlib.i686'
This should start the adb.
The available devices can be seen by running :
adb devices
The next challenge is that the adb doesn't recognise the USB device plugged in.
The following message shows up on runnning "adb devices" command.
????????????? Permission Denied
To remedy this, run the following commands in the terminal.
sudo gedit /etc/udev/rules.d/51-android.rules
On opening text editor, paste the following lines in it. Save and exit.
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="04dd", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="054c", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="0fce", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="2340", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="0930", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="0502", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="0b05", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="413c", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="0489", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="04c5", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="091e", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="05c6", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="04da", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="0471", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="1d4d", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="10a9", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="19d2", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="201E", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="109b", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="12d1", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="24e3", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="2116", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="0482", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="17ef", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="1004", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="0e8d", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="0409", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="2080", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="0955", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="2257", MODE="0666", GROUP="plugdev"
These commands tells the system the Vendor ID of all major android
manufacturing companies so that adb could be run properly on all devices.
Follow it up by this command :
chmod a+r /etc/udev/rules.d/51-android.rules
Now, almost all devices are recognized by adb.
Refer http://developer.android.com/tools/device.html
for further reference on adb and udev.
You are all set for developing awesome android applications. Go for it.
@haridas
Copy link

haridas commented Sep 28, 2015

Thanks for sharing. Very informative and every thing in one place 👍

@ArcaneEngineer
Copy link

ArcaneEngineer commented May 26, 2016

Addition: You must manually run the SDK manager after downloading / extracting the SDK:

$ /path/to/android-sdk-linux/tools/android sdk

...and pull the platform-tools (without which you have no adb) and whatever else you need, e.g. SDK API levels etc.

The latest download packages do not include these.

Copy link

ghost commented Jun 13, 2016

The newest ones even don't download android development tools, can you please help?? thanks in advance

@spach10
Copy link

spach10 commented Jul 20, 2017

Go here to download the tools https://developer.android.com/studio/command-line/index.html

After unzipping what's downloaded you can run the command
$ /path/to/android-sdk/tools/bin/sdkmanager "platform-tools"
This will allow you to have access to all adb commands

@festum
Copy link

festum commented Dec 22, 2020

SDK link is outdated. sdkmanager from snapcraft is more proper https://snapcraft.io/androidsdk.

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