13

I just got a brand new Ubuntu machine and I am trying to setup Android SDK. I am pretty new to Unix so pardon me if I did a silly mistake.

I followed the instructions given here, all the way up to adding the 'Rule' file. Now if I try adb devices in the terminal, it gives me 'No command 'adb' found' error and asks if I made a spelling mistake.

@USER:~/android-sdk-linux/platform-tools$ ls
NOTICE.txt  adb  api  fastboot  source.properties  systrace
@USER:~/android-sdk-linux/platform-tools$ adb devices
No command 'adb' found, did you mean:
 Command 'cdb' from package 'tinycdb' (main)
 Command 'gdb' from package 'gdb' (main)
 Command 'dab' from package 'bsdgames' (universe)
 Command 'zdb' from package 'zfs-fuse' (universe)
 Command 'kdb' from package 'elektra-bin' (universe)
 Command 'tdb' from package 'tads2-dev' (multiverse)
 Command 'pdb' from package 'python' (main)
 Command 'jdb' from package 'openjdk-6-jdk' (main)
 Command 'jdb' from package 'openjdk-7-jdk' (universe)
 Command 'ab' from package 'apache2-utils' (main)
 Command 'ad' from package 'netatalk' (universe)
adb: command not found

I searched through a couple of questions on StackOverflow and some suggest I use apt-get install ia32-libs command to get some 32-bit libraries. However, I am on a 64-bit machine so not sure whether I should go for that or not.

Another strange issue I noticed is, even if I navigate to the platform-tools folder and execute adb devices command, I get the same error. So, I might be missing something else here rather than incorrectly setting the PATH entry.

I tried both the ADB BUNDLE (.zip file) and SDK tools (.tgz file) from the download page and completed all the steps mentioned above but got same error.

I am on Ubuntu 12.04 LTS.

Community
  • 1
  • 1
rumit patel
  • 1,891
  • 5
  • 23
  • 28
  • 1
    The current directory is not in your `$PATH`. – Santa Dec 11 '13 at 23:58
  • echo $PATH gives me this: /usr/lib/lightdm/lightdm:/usr/local/bin:/usr/bin:/bin ---> So how does that matter if the current directory is not in my PATH. 'adb' command should work if I am directly into that directory/folder, isn't it? – rumit patel Dec 12 '13 at 00:09
  • When you launch a command like that, the shell will only look for it in `$PATH`. It's not implicit that the current directory is also looked at. If you want that behavior, you need to also add the current directory (`.`) to `$PATH`. – Santa Dec 12 '13 at 00:38
  • The alternative, if you do not want to mess with `$PATH`, is to qualify it like: `shell$ ./adb ` – Santa Dec 12 '13 at 00:39
  • The advice to cd to the platform tools folder comes from people familiar with windows. Most sane shells (even bash on windows) don't have the current directory in the path so that people don't accidentally run things they don't mean to. Therefore going to that directory won't by itself work. – Chris Stratton Dec 12 '13 at 01:48
  • another solution, maybe it helps somebody.. http://stackoverflow.com/a/26801406/3106975 – Mike Spike Nov 07 '14 at 12:40

5 Answers5

28

You are in the right directory but the current directory is not in your shell's command search path.

Try

./adb

Also search Google for how to set $PATH variable in bash

Type the following into your terminal (from your help.ubuntu.com URL) - it will temporarily add the android tool directories into your PATH for that shell/terminal

export PATH=${PATH}:~/android-sdk-linux/tools
export PATH=${PATH}:~/android-sdk-linux/platform-tools

You should now be able to run adb (without being in the right dir and without using ./adb)

If you add those commands into your .bashrc and start a new terminal/shell you should find those changes are now permanent.

abasterfield
  • 2,214
  • 12
  • 17
  • echo $PATH gives me this: /usr/lib/lightdm/lightdm:/usr/local/bin:/usr/bin:/bin ---> So how does that matter if the current directory is not in my PATH. 'adb' command should work if I am executing it directly from that directory/folder, isn't it? Also, tried './adb' but I get 'No such file or directory'. I had added them to my PATH but even that did not work. I restarted my machine after all the changes and still got same issues. – rumit patel Dec 12 '13 at 00:17
  • No the current directory is not in your command search path $PATH by default. You can add it but it is generally a bad idea. – abasterfield Dec 12 '13 at 00:20
21

Make sure you installed:

sudo apt-get install android-tools-adb

Now check:

sudo adb

It will show adb help.

Now please kill/start adb. Use the following commands:

sudo adb kill-server
sudo adb start-server

Lastly, do:

sudo adb devices

This should work.

skuntsel
  • 11,624
  • 11
  • 44
  • 67
Nikhil Raut
  • 550
  • 5
  • 12
1

I'm not sure what this line did and why I had to do that ('cuz the blogs say its some 32-bit libraries and I am on a 64-bit machine). But it seems to be working for me.

sudo apt-get install ia32-libs

When I executed this command, it installed/added some stuff for about 5 minutes (literally) and then everything worked.

Regards, Rumit

rumit patel
  • 1,891
  • 5
  • 23
  • 28
  • This adds support libraries needed for running 32 bit programs on 64 bit Linux. – Chris Stratton Dec 12 '13 at 01:51
  • Ran into the same issue with adb being present but not executed on a Docker instance of Ubuntu. This didn't immediately fix the problem, but it's pointed me in the right direction! – David Doyle May 10 '16 at 16:36
0

In platform-tools folder "adb" is available then follow these steps:

Set android vars

Initially go to your home and press Ctrl + H it will show you hidden files now look for .bashrc file, open it with any text editor then place the lines below at the end of file:

export ANDROID_HOME=/myPathSdk/android-sdk-linux export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

Now Reboot the system

It Works!

Nithin Raja
  • 1,144
  • 12
  • 11
0

(My system is ubuntu 16.10)

This will make the android studio to find the adb-->

1) Open with gedit: (ref:https://askubuntu.com/questions/127056/where-is-bashrc)

gedit ~/.bashrc

2) Add this line to the bottom of your.bashrc and it works.

export PATH=$PATH:$HOME"/android-sdk-linux/platform-tools" (ref: https://askubuntu.com/questions/652936/adding-android-sdk-platform-tools-to-path-downloaded-from-umake)

Restart the android studio

Pradip Tilala
  • 1,715
  • 16
  • 24