Android 找不到 adb 命令

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10303639/
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 03:13:05  来源:igfitidea点击:

adb command not found

androidmacosterminaladb

提问by coure2011

I need to run an adb forwardcommand before I could use the ezkeyboardapplication which allows user to type on the phone using browser.

我需要先运行一个adb forward命令,然后才能使用ezkeyboard应用程序,该应用程序允许用户使用浏览器在手机上打字。

When I run adb forward tcp:8080 tcp:8080command I get the adb command not founderror message.

当我运行adb forward tcp:8080 tcp:8080命令时,我收到adb command not found错误消息。

I can run androidcommand from terminal. Why adbis not working?

我可以android从终端运行命令。为什么adb不工作?

采纳答案by kevoroid

Make sure adbis in your user's $PATHvariable.

确保adb在您用户的$PATH变量中。

or

或者

You can try to locate it with whereisand run it with ./adb

您可以尝试使用它来定位whereis并运行它./adb

回答by Denis Kutlubaev

In my case with Android Studio 1.1.0 path was this

就我而言,Android Studio 1.1.0 路径是这样的

/Users/wzbozon/Library/Android/sdk/platform-tools

/Users/wzbozon/Library/Android/sdk/platform-tools

Add the following to ~/.bash_profile

将以下内容添加到 ~/.bash_profile

export PATH=~/Library/Android/sdk/tools:$PATH
export PATH=~/Library/Android/sdk/platform-tools:$PATH

回答by Vaibhav Desai

I am using Mac 10.11.1 and using android studio 1.5, I have my adb "/Users/user-name/Library/Android/sdk/platform-tools"

我正在使用 Mac 10.11.1 并使用 android studio 1.5,我有我的 adb "/Users/user-name/Library/Android/sdk/platform-tools"

Now edit you bash_profile

现在编辑你 bash_profile

emacs ~/.bash_profile

Add this line to your bash_profile, and replace the user-name with your username

将此行添加到您的 bash_profile,并将用户名替换为您的用户名

export PATH="$PATH:/Users/user-name/Library/Android/sdk/platform-tools"

save and close. Run this command to reload your bash_profile

保存并关闭。运行此命令以重新加载您的 bash_profile

source ~/.bash_profile

回答by Mike Collins

Is adb installed? To check, run the following command in Terminal:

adb 安装了吗?要检查,请在终端中运行以下命令:

~/Library/Android/sdk/platform-tools/adb

If that prints output, skip these following install steps and go straight to the final Terminal command I list:

如果打印输出,请跳过以下安装步骤并直接进入我列出的最终终端命令:

  1. Launch Android Studio
  2. Launch SDK Manager via Tools -> Android -> SDK Manager
  3. Check Android SDK Platform-Tools
  1. 启动 Android Studio
  2. 通过 Tools -> Android -> SDK Manager 启动 SDK Manager
  3. 检查 Android SDK Platform-Tools

Run the following command on your Mac and restart your Terminal session:

在 Mac 上运行以下命令并重新启动终端会话:

echo export "PATH=~/Library/Android/sdk/platform-tools:$PATH" >> ~/.bash_profile

Note: If you've switched to zsh, the above command should use .zshenvrather than .bash_profile

注意:如果你已经切换到 zsh,上面的命令应该使用.zshenv而不是.bash_profile

回答by par

From the file android-sdks/tools/adb_has_moved.txt:

从文件 android-sdks/tools/adb_has_moved.txt:

The adb tool has moved to platform-tools/

If you don't see this directory in your SDK, launch the SDK and AVD Manager (execute the android tool) and install "Android SDK Platform-tools"

Please also update your PATH environment variable to include the platform-tools/ directory, so you can execute adb from any location.

adb 工具已移至 platform-tools/

如果您在 SDK 中没有看到此目录,请启动 SDK 和 AVD 管理器(执行 android 工具)并安装“Android SDK Platform-tools”

还请更新您的 PATH 环境变量以包含 platform-tools/ 目录,以便您可以从任何位置执行 adb。

so on UNIX do something like:

所以在 UNIX 上做这样的事情:

export PATH=$PATH:~/android-sdks/platform-tools

export PATH=$PATH:~/android-sdks/platform-tools

回答by Atul

This is the easiest way and will provide automatic updates.

这是最简单的方法,将提供自动更新。

  1. install homebrew

    ruby -e "$(curl -fsSL 
    https://raw.githubusercontent.com/Homebrew/install/master/install)"
    
  2. Install adb

    brew cask install android-platform-tools
    
  3. Start using adb

    adb devices
    
  1. 安装自制软件

    ruby -e "$(curl -fsSL 
    https://raw.githubusercontent.com/Homebrew/install/master/install)"
    
  2. 安装亚行

    brew cask install android-platform-tools
    
  3. 开始使用 adb

    adb devices
    

回答by Muneef M

Mac users just open /Users/(USERNAME)/.bash_profilethis file in a editor.
and add this line to add path.

Mac 用户只需/Users/(USERNAME)/.bash_profile在编辑器中打开此文件。
并添加此行以添加路径。

export PATH="/Users/myuser/Library/Android/sdk/platform-tools":$PATH

this is the default path if you install adb via studio. and dont forget to change the username in this line.

如果您通过 studio 安装 adb,这是默认路径。并且不要忘记更改此行中的用户名。

回答by Anky An

Type the below command in terminal:

在终端中输入以下命令:

nano .bash_profile

纳米 .bash_profile

And add the following lines (replace USERNAME with your own user name).

并添加以下几行(用您自己的用户名替换 USERNAME)。

export ANDROID_HOME=/Users/USERNAME/Library/Android/sdk 
export PATH=${PATH}:${ANDROID_HOME}/tools 
export PATH=${PATH}:${ANDROID_HOME}/platform-tools

Close the text editor, and then enter the command below:

关闭文本编辑器,然后输入以下命令:

source .bash_profile

源 .bash_profile

回答by IgniteCoders

If you don't want to edit PATHvariable, go to the platform-toolsdirectory where the SDKis installed, and the command is there.

如果不想编辑PATH变量,请到安装platform-tools目录,SDK命令就在那里。

You can use it like this:

你可以这样使用它:

  1. Go to the directory where you placed the SDK:

    cd /Users/mansour/Library/Developer/Android/sdk/platform-tools

  2. Type the adbcommand with ./to use it from the current directory.

    ./adb tcpip 5555

    ./adb devices

    ./adb connect 192.168.XXX.XXX

  1. 转到您放置的目录SDK

    cd /Users/mansour/Library/Developer/Android/sdk/platform-tools

  2. 键入adb命令以./从当前目录使用它。

    ./adb tcpip 5555

    ./adb devices

    ./adb connect 192.168.XXX.XXX

回答by Snowcrash

On my Mac (OS X 10.8.5) I have adb here:

在我的 Mac (OS X 10.8.5) 上,我有 adb:

~/Library/android-sdk-mac_86/platform-tools

So, edit the $PATHin your .bash_profileand sourceit.

所以,编辑$PATH.bash_profilesource它。