Android 在 linux 环境中找不到 adb 命令

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2517493/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 06:08:48  来源:igfitidea点击:

adb command not found in linux environment

androidadb

提问by Praween k

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

在 G1 设备中实现 BluetoothChat 应用程序 .apk 时,它总是弹出一条消息:

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

I am not getting clearly why this error is popping up every time. Please help me.

我不清楚为什么每次都会弹出这个错误。请帮我。

Thanks in advance. Praween

提前致谢。普拉温

回答by mabac

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

我找到了解决我的问题的方法。在我的~/.bashrc

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

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

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

然而adb并不位于android-sdk/tools/,而是位于android-sdk/platform-tools/。所以我添加了以下内容

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

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

And that solved the problem for me.

这为我解决了这个问题。

回答by crazymacleod

Updating the path as listed above in ~/.bashrc makes other bash commands stop working all together. the easiest way I found is to use what eaykin did but link it your /bin.

更新 ~/.bashrc 中上面列出的路径会使其他 bash 命令停止一起工作。我发现的最简单的方法是使用 eaykin 所做的,但将其链接到您的 /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.

以确保它正常工作。

回答by zmalltalker

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

我在新的 Ubuntu 64 位安装上遇到了同样的问题,并且路径设置正确。

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

因此,which adb会正确解析,但尝试运行它会失败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.

#android-dev 非常有帮助的人向我指出了解决方案,即尚未安装 32 位库。在我以前的计算机上,这可能是作为另一个包的依赖项引入的。

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

在 Ubuntu(也可能是其他 Debian)上,运行 [sudo] apt-get install ia32-libs

回答by gal007

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:

注意:在 Linux 上使用 adb 时,除非您在 ~/.bashrc 中创建路径,否则您需要键入 ./adb 来执行 adb 命令。在终端写:

sudo gedit ~/.bashrc

须藤 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

导出路径=~/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:

然后在终端中运行此命令以重新加载您的 .bashrc:代码:

source ~/.bashrc

源 ~/.bashrc

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

现在你可以在每个命令之前运行 adb 而不用 put ./ 。

回答by Gautam

sudo apt install adb

sudo apt 安装 adb

in your pc adb not installed.

在你的电脑 adb 没有安装。

Try this, working for me

试试这个,为我工作

回答by Nithin Raja

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!
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

然后将以下行放在文件末尾:

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


Now Reboot the system

It Works!

回答by CommonsWare

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

您需要添加$ANDROID_SDK/platform-tools到您的PATH, where$ANDROID_SDK是您安装 Android SDK 的位置。

回答by res

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

我和你有同样的问题。最后据我所知,在 linux 和 mac OS 中,我们使用./adb而不是adb

回答by Sergey

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.

我刚刚在 mint(ubuntu) 上自己解决了这个问题。至少根据 readelf -h,adb 似乎是一个 32 位可执行文件。要使程序在 64 位 ubuntu 或任何安装中工作,我们必须有 32 位库。

solved the problem with

解决了这个问题

sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386

回答by Daniel Eduardo Delgado Diaz

Ubuntu 18.04

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 devicesis now working
  1. 找出并复制平台工具路径,在我的情况下是 '/home/daniel/Android/Sdk/platform-tools'
  2. 打开 bashrc nano ~/.bashrc
  3. 保存平台工具路径 export PATH="${PATH}:/home/daniel/Android/Sdk/platform-tools"
  4. 重置 bash_profile source .bash_profile
  5. adb devices现在正在工作