无法通过终端访问OS X中的adb,“命令未找到"; [英] Not able to access adb in OS X through Terminal, "command not found"

查看:123
本文介绍了无法通过终端访问OS X中的adb,“命令未找到";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Mac系统上安装了Android SDK和Eclipse.我能够使用Eclipse进行编程,并且创建了一些示例应用程序.但是我仍然无法通过终端窗口访问adb.我在终端中尝试了以下命令:

I have installed Android SDK and Eclipse on my Mac system. I am able to program using Eclipse and have created few sample applications. But I am still not able to access adb through the terminal window. I have tried following command in terminal:

$ pwd
/Users/espireinfolabs/Desktop/soft/android-sdk-mac_x86/platform-tools

$ ls
NOTICE.txt  dexdump     llvm-rs-cc-2
aapt        dx          llvm-rs-cc.txt
adb         lib         source.properties
aidl        llvm-rs-cc

$ adb --help
-bash: adb: command not found

我还添加了ls输出,以便您知道我在哪个窗口中.

I have also added the ls output so that you know in which window I am.

推荐答案

问题是: adb不在您的PATH中..这是外壳程序在其中查找可执行文件的地方.您可以使用echo $PATH检查当前的PATH.

The problem is: adb is not in your PATH. This is where the shell looks for executables. You can check your current PATH with echo $PATH.

Bash首先会尝试在您的Path(而不是当前目录)中查找名为adb的二进制文件.因此,如果您当前位于platform-tools目录中,只需致电

Bash will first try to look for a binary called adb in your Path, and not in the current directory. Therefore, if you are currently in the platform-tools directory, just call

./adb --help

点是您当前的目录,这告诉Bash从那里使用adb.

The dot is your current directory, and this tells Bash to use adb from there.

但是,实际上,您应该在PATH 中添加platform-tools以及Android SDK随附的其他一些工具.这是您的操作方式:

But actually, you should add platform-tools to your PATH, as well as some other tools that the Android SDK comes with. This is how you do it:

  1. 查找安装Android SDK的位置.这可能是以下位置之一(其中$HOME是用户的主目录)(或通过Android Studio启动屏幕中的 Configure> SDK Manager 进行验证)

  1. Find out where you installed the Android SDK. This might be (where $HOME is your user's home directory) one of the following (or verify via Configure > SDK Manager in the Android Studio startup screen):

  • Linux:$HOME/Android/Sdk
  • macOS:$HOME/Library/Android/sdk
  • Linux: $HOME/Android/Sdk
  • macOS: $HOME/Library/Android/sdk

找出要编辑的外壳配置文件,取决于哪个文件二手:

Find out which shell profile to edit, depending on which file is used:

  • Linux:通常为$HOME/.bashrc
  • macOS:通常为$HOME/.bash_profile
  • 使用Zsh:$HOME/.zshrc
  • Linux: typically $HOME/.bashrc
  • macOS: typically $HOME/.bash_profile
  • With Zsh: $HOME/.zshrc

打开第二步中的外壳配置文件,并在文件底部添加以下行.如果路径不同,请确保将路径替换为您安装的路径platform-tools

Open the shell profile from step two, and at the bottom of the file, add the following lines. Make sure to replace the path with the one where you installed platform-tools if it differs:

export ANDROID_HOME="$HOME/Android/Sdk"
export PATH="$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools:$PATH"

  • 保存配置文件,然后重新启动终端或运行source ~/.bashrc(或刚刚修改的任何内容).

  • Save the profile file, then, re-start the terminal or run source ~/.bashrc (or whatever you just modified).

    请注意,某些第三方框架需要设置ANDROID_HOME,因此添加它不会有任何损害.

    Note that setting ANDROID_HOME is required for some third party frameworks, so it does not hurt to add it.

    这篇关于无法通过终端访问OS X中的adb,“命令未找到";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆