Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Debug Bridge (adb) command line tool exists in $PATH, but "command not found" in linux

sudo echo $PATH

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/lubuntu/Tools/android-sdk-linux/platform-tools

adb exists in /home/lubuntu/Tools/android-sdk-linux/platform-tools

Then I executed adb start-server:

* daemon not running. starting it now on port 5037 *
* daemon started successfully *

Then sudo adb install test.apk

sudo: adb: command not found

I have added adb in the environment variable $PATH, but sudo couldn't find it. Why?

like image 680
Searene Avatar asked Feb 24 '12 10:02

Searene


2 Answers

sudo means you're switching to root, and that does not necessarily mean that your environment comes along. That could be dangerous.

At your risk, add the -E option to inherit the calling environment.

like image 135
unwind Avatar answered Nov 14 '22 22:11

unwind


The problem is the PATH var is set for that user, and root don't have the aditional PATH entry, so it can't found the program.

You should setup adb for root too:

adb Environmental Variables

Open ~/.bashrc and add the following to the very bottom

export PATH=${PATH}:<sdk>/tools:<sdk>/platform-tools

Change <sdk> to the actual path. ie /home/user/android-sdk-linux Close and re-open your terminal to refresh variables.

from adb setup

If doesn't work, make symbolic links from adb and other binaries to /usr/local/bin

like image 39
Paulo Fidalgo Avatar answered Nov 14 '22 21:11

Paulo Fidalgo