70

While implementing the BluetoothChat application .apk inside G1 device, it always pops up a message:

$adb install -r /home/parveen/workspace/BluetoothChat/bin/BluetoothChat.apk 
-bash: adb: command not found

Why is this error popping up every time, and how can the problem be fixed?

starball
  • 20,030
  • 7
  • 43
  • 238
Praween k
  • 1,005
  • 1
  • 10
  • 23

25 Answers25

114

Updating the path as listed above in ~/.bashrc makes other bash commands stop working altogether.

the easiest way I found is to use what eaykin did but link it your /bin.

sudo ln -s /android/platform-tools/adb /bin/adb

No restart is required just type following command :

adb devices

To make sure it's working.

Mostafa Norzade
  • 1,578
  • 5
  • 24
  • 40
crazymacleod
  • 1,141
  • 1
  • 7
  • 2
103

I found the solution to my problem. In my ~/.bashrc:

export PATH=${PATH}:/path/to/android-sdk/tools

However adb is not located in the android-sdk/tools/, rather in android-sdk/platform-tools/. So I added the following

export PATH=${PATH}:/path/to/android-sdk/tools:/path/to/android-sdk/platform-tools

And that solved the problem for me.

Alex P.
  • 30,437
  • 17
  • 118
  • 169
mabac
  • 1,420
  • 1
  • 10
  • 6
22

sudo apt install adb

in your pc adb not installed.

Try this, working for me

Gautam
  • 1,345
  • 12
  • 30
  • 5
    Please note this is in cases where adb exists due to Android Studio but cannot be found. Reinstalling via the apt may cause further issues. – Chandrahas Aroori Jan 26 '21 at 06:58
17

NOTE: while using adb on Linux you'll need to type ./adb to execute adb commands unless you create a path in ~/.bashrc. In a terminal write:

sudo gedit ~/.bashrc

Add the following line at the end of the file. Once you're done, save and exit.

Android tools

export PATH=~/Development/adt-bundle-linux/sdk/platform-tools:~/Development/adt-bundle-linux/sdk/tools:$PATH

Then in a Terminal run this command to reload your .bashrc: Code:

source ~/.bashrc

Now you can just run adb without put ./ before every command.

gal007
  • 6,911
  • 8
  • 47
  • 70
17

I had the same issue on my fresh Ubuntu 64 bit installation, and the path was set up correctly.

Thus, which adb would resolve correctly, but trying to run it would fail with adb: command not found.

The very helpful guys at #android-dev pointed me to the solution, namely that the 32 bit libraries hadn't been installed. On my previous computers, this had probably been pulled in as a dependency for another package.

On Ubuntu (probably other Debians as well), running [sudo] apt-get install ia32-libs

zmalltalker
  • 511
  • 1
  • 6
  • 6
  • see also http://serverfault.com/questions/415073/ia32-libs-depends-ia32-libs-i386-but-it-is-not-installable – Julian Jun 01 '13 at 02:05
11

Ubuntu 18.04

This worked for me:

  1. Find out and copy platform-tools path, in my case is '/home/daniel/Android/Sdk/platform-tools'
  2. Open bashrc nano ~/.bashrc
  3. Save platform-tools path export PATH="${PATH}:/home/daniel/Android/Sdk/platform-tools"
  4. Reset bash_profile source .bash_profile
  5. adb devices is now working
Daniel Delgado
  • 4,813
  • 5
  • 40
  • 48
  • 2
    Works also on Ubuntu 20.04, instead of the 4. step, you can just restart terminal (I can't find `.bash_profile` file.). – Vít Kapitola Mar 25 '21 at 07:42
8

You need to add $ANDROID_SDK/platform-tools to your PATH, where $ANDROID_SDK is wherever you installed the Android SDK.

Alex P.
  • 30,437
  • 17
  • 118
  • 169
CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • if we keep on adding program directories to $PATH, won't it take longer for each command to run, because now more locations have to be accessed to find where the command is. – Rohan Bhatia Jan 03 '18 at 12:34
  • 2
    @RohanBhatia: If finding programs on the `PATH` is a significant amount of overhead on your development machine, you may need a new development machine. For example, I just ran the Linux command `time which adb`, where `which` searches the `PATH` for `adb` and `time` prints the amount of time the rest of the command took. That took 2 milliseconds. That's with ~20 directories in my `PATH`, some of which have hundreds of commands. – CommonsWare Jan 03 '18 at 12:45
  • I was just listing a possibility. I didn't know it takes only this much time to search for the command. – Rohan Bhatia Jan 03 '18 at 12:54
  • Should I create a symbolic link of the command in `usr/bin` or `~/bin` directory or add the path of this command to the `PATH env variable`? – Rohan Bhatia Jan 03 '18 at 12:57
  • 1
    @RohanBhatia: I strongly recommend that you add it to the `PATH` environment variable. – CommonsWare Jan 03 '18 at 12:57
  • And to do that I need to edit `etc/environment`, right? – Rohan Bhatia Jan 03 '18 at 12:59
  • I used `export PATH=$PATH:NEW/PATH`, but this only worked for current session. – Rohan Bhatia Jan 03 '18 at 13:02
  • Another way is to execute `export command` each time I login by adding it to `~/.profile`. Which way should I follow? – Rohan Bhatia Jan 03 '18 at 13:09
  • 1
    @RohanBhatia: That will depend on the conventions used by your Linux distro. – CommonsWare Jan 03 '18 at 13:17
8
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
6

For Ubuntu 20.04

After trying many solution

sudo apt install adb

worked for me.

After installing try command adb devices for starting daemon successfully then again use same command adb devices to get the list of devices

Lakshya Tyagi
  • 79
  • 1
  • 5
5

I have same problem as you. finally as i know, in linux & mac OS, we use ./adb instead of adb

res
  • 69
  • 1
  • 1
  • 1
    In linux, you can also use adb. You just need add a path to adb command in your environment. You just need to edit bashrc file and add a path to adb command there. It should work fine after that. – VendettaDroid Sep 22 '12 at 10:41
5

In my case "adb" is located in "~/Android/Sdk/platform-tools/"

the following command solved the problem:

export PATH=$PATH:~/Android/Sdk/platform-tools/
Ahmed Abdeldaim
  • 121
  • 1
  • 11
3

I have just resolved the problem myself on mint(ubuntu). It seems that adb is a 32 bit executable at least according to readelf -h. for the program to work in 64-bit ubuntu or whatever installation, we must have 32-bit libraries inplace.

solved the problem with

sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386
Alex P.
  • 30,437
  • 17
  • 118
  • 169
Sergey
  • 749
  • 6
  • 13
2

The way I fix this problem is:

  1. create a link from adb file(drag 'adb' with holding alt then drop to any directory and select 'link here')
  2. use #sudo cp adb /bin (copy link from 1 to /bin)

I've done this several times and it works 100%(tested on Ubuntu 12.04 32/64bit).

bool.dev
  • 17,508
  • 5
  • 69
  • 93
2

adb is in android-sdks/tools directory. You simply type this command: adb logcat.

If you want to your stack traces in a text file use this command: adb logcat > trace.txt. Now your traces are copied into that file.

If it is not working then go to android-sdks/platform-tools then put this command: ./adb logcat > trace.txt. Hope it will helps to you.

Sean O'Toole
  • 4,304
  • 6
  • 35
  • 43
Dinesh
  • 965
  • 2
  • 11
  • 23
2

In Ubuntu i could run the following command:

  sudo apt install android-tools-adb
Ahmad Shabib
  • 109
  • 5
  • 2
    Please augment your code-only answer with some explanation, in order to reduce the impression that StackOverflow is a free code writing service. – Yunnosch Dec 19 '17 at 19:08
1

Make sure you installed sudo apt-get install android-tools-adb Now check sudo adb It will show help of adb

Now please kill/start adb use following commands -

sudo adb kill-server sudo adb start-server

Lastly, sudo adb devices

Hopefully this will work !!!

Nikhil Raut
  • 550
  • 5
  • 12
1

I had this problem when I was trying to connect my phone and trying to use adb. I did the following

  1. export PATH=$PATH{}:/path/to/android-sdk/tools:/path/to/android/platform-tools

  2. apt-get install ia32-libs

  3. Connected my phone in USB debug mode and In the terminal type lsusb to get a list of all usb devices. Noted the 9 character (xxxx:xxxx) ID to the left of my phone.

  4. sudo gedit /etc/udev/rules.d/99-android.rules

  5. Add [ SUBSYSTEM=="usb", ATTRS{idVendor}=="####:####", SYMLINK+="android_adb", MODE="0666" GROUP="plugdev" TEST=="/var/run/ConsoleKit/database", \ RUN+="udev-acl --action=$env{action} --device=$env{DEVNAME}" ] (whatever is in [...] )to the file and replace "####:####" with the number from step 3cop

  6. sudo service udev restart

  7. Restarted my System

  8. open terminal browse to adb directory and run ./adb devices

And it shows my phone hence adb starts working without error.

I hope it helps others

Khurram Majeed
  • 2,291
  • 8
  • 37
  • 59
0

I was getting this error also and Ubuntu suggested me to install it so I installed* it and this worked in my case.
* - sudo apt-get install android-tools-adb

Note:x64 architecture

Mike Spike
  • 389
  • 8
  • 20
0

creating a symbolic link was the solution for me either. However before working I had to grant access and execute rights to the created symbolic links.

I am not sure if it was @eaykin's answer or @crazymacleod's that worked for me, as I did both before finding the above mentioned solution.

Thanks!

geraldCelente
  • 1,005
  • 2
  • 16
  • 36
0

updating the $PATH did not work for me, therefore I added a symbolic link to adb to make it work, as follows:

ln -s <android-sdk-folder>/platform-tools/adb <android-sdk-folder>/tools/adb
eaykin
  • 3,713
  • 1
  • 37
  • 33
0

For Fedora

sudo dnf install adb 
siva balan
  • 389
  • 3
  • 6
0

Please try to update your bash profile.

For linux users: You need to add your Android SDK location.

For MAC users , in addition to the above step one extra change is required: You also need to add your Android Platform Tools location.

For more detail you can watch this video for reference: https://youtu.be/0-S5a0eXPoc?t=1211

0

WHAT WORKED FOR ME:

 1. nano ~/.zshrc
        or
  nano ~/.bashrc

 
2. alias adb='~/Android/Sdk/platform-tools/adb'

Home this helps you out.

Mr Coolman
  • 29
  • 4
0

Steps to install ADB in arch linux using pacman

  1. It is crucial to make sure your system is up to date before installing ADB. Run the following command in your terminal as the root user to do this.
  2. sudo pacman -Syyu
  3. After updating your system again,
  4. sudo pacman -S android-tools
  5. When asked hit enter to yes
  6. And you are done.
0

None of the solutions here worked for me. It was driving me nuts because adb would work fine in a terminal window, but not in Android Studio's terminal.

After enough messing around, I finally found that for some reason under Settings -> Tools -> Terminal, the Shell path was not set to /bin/bash. (I don't remember what it was originally set to now and I can't see it anymore, it was something to do with sh)

Changing this to /bin/bash solved the problem for me.

rjr-apps
  • 352
  • 4
  • 13