无法通过终端访问OS X中的adb,“命令未找到"; [英] Not able to access adb in OS X through Terminal, "command not found"
问题描述
我已经在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:
-
查找安装Android SDK的位置.这可能是以下位置之一(其中
$HOME
是用户的主目录)(或通过Android Studio启动屏幕中的 Configure> SDK Manager 进行验证)
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屋!