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

$ 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输出,以便您知道我在哪个窗口。


当前回答

对于Mac, Android Studio 3.6.1,我将此添加到.bash_profile

导出路径= " ~ /图书馆/ Android / sdk /平台工具/平台工具”:美元的道路

其他回答

更新

@Loren。评论中提到的最新版本的brew不支持强制转换。所以你可以简单地用:

酿造安装android-platform-tools


只需使用brew安装adb 酿造桶安装android-platform-tools 检查是否安装了adb 亚洲开发银行设备

除了slhck之外,这也是我所使用的(mac)。

检查sdk的位置。

打开Android工作室,转到:

文件->项目结构-> Sdk位置

复制路径。 在家中创建隐藏的.bash_profile。 (使用vim打开它,或打开-e),使用以下命令:


export PATH=/Users/<Your session name>/Library/Android/sdk/platform-tools:/Users/<Your session name>/Library/Android/sdk/tools:$PATH

然后在您的终端中简单地使用这个:。~ / . bash_profile

SO关于如何找到adb设备的帖子

问题是:adb不在您的PATH中。这是shell查找可执行文件的地方。你可以用echo $PATH检查你当前的路径。

Bash将首先尝试在Path中查找名为adb的二进制文件,而不是在当前目录中。因此,如果您当前在platform-tools目录中,只需调用

./adb --help

圆点是您的当前目录,它告诉Bash从那里使用adb。

但实际上,你应该在PATH中添加平台工具,以及Android SDK附带的其他一些工具。你可以这样做:

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 Find out which shell profile to edit, depending on which file is used: Linux: typically $HOME/.bashrc macOS: typically $HOME/.bash_profile With Zsh: $HOME/.zshrc 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" Save the profile file, then, re-start the terminal or run source ~/.bashrc (or whatever you just modified).

注意,某些第三方框架需要设置ANDROID_HOME,所以添加它也无妨。

对我来说,我从bash切换到zsh后就遇到了这个问题,这样我就可以用Hyper和时髦的主题让我的控制台看起来非常棒。我试图使用react-native run-android运行我的react-native应用程序,并遇到了操作的问题。添加以下到我的~。ZSHRC文件为我解决了这个问题:

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

对于Mac, Android Studio 3.6.1,我将此添加到.bash_profile

导出路径= " ~ /图书馆/ Android / sdk /平台工具/平台工具”:美元的道路