问题描述
在找到有关如何为Mac设置ADB的可靠教程时,我遇到了问题.
I had issues finding a good solid tutorial on how to setup ADB for Mac.
如何将 ADB 添加到 macOS ,以便可以在终端中使用它?
How can I add ADB to macOS in such a way that it can be used in the terminal?
更新
对于那些阅读这篇文章的人.是的,正如编辑后的回复所述.当时我正在寻找一个包含所有步骤的教程,作为初学者级指南.
For those reading this post. Yes, as the edited response says. I was at the time looking for a tutorial with all steps as a beginner level guide.
与在Mac OS X上设置adb 不同,这个问题的目的是提供一个所有的教程,其中包含在macOS上获取ADB所需的安装步骤.
Unlike Set up adb on Mac OS X, the intention of this question is to have a tutorial with all of the required installation steps to get ADB on macOS.
推荐答案
选项1-使用自制软件
这是最简单的方法,它将提供自动更新.
Option 1 - Using Homebrew
This is the easiest way and will provide automatic updates.
-
安装自制软件
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
安装adb
Install adb
brew cask install android-platform-tools
开始使用adb
Start using adb
adb devices
这是手动安装ADB和Fastboot的最简单方法.
This is the easiest way to get a manual installation of ADB and Fastboot.
-
删除旧安装(可选)
rm -rf ~/.android-sdk-macosx/
导航到 https://developer.android.com/studio /releases/platform-tools.html 并单击SDK Platform-Tools for Mac
链接.
Navigate to https://developer.android.com/studio/releases/platform-tools.html and click on the SDK Platform-Tools for Mac
link.
转到下载"文件夹
cd ~/Downloads/
解压缩下载的工具
Unzip the tools you downloaded
unzip platform-tools-latest*.zip
将它们移动到不会意外删除它们的地方
Move them somewhere you won't accidentally delete them
mkdir ~/.android-sdk-macosx
mv platform-tools/ ~/.android-sdk-macosx/platform-tools
将platform-tools
添加到您的路径
Add platform-tools
to your path
echo 'export PATH=$PATH:~/.android-sdk-macosx/platform-tools/' >> ~/.bash_profile
刷新您的bash个人资料(或重新启动您的终端应用程序)
Refresh your bash profile (or restart your terminal app)
source ~/.bash_profile
开始使用adb
Start using adb
adb devices
选项3-手动(使用SDK Manager)
-
删除旧安装(可选)
rm -rf ~/.android-sdk-macosx/
从Android开发人员网站的>获取下下载Mac SDK工具只是命令行工具" .确保将它们保存到下载"文件夹中.
Download the Mac SDK Tools from the Android developer site under "Get just the command line tools". Make sure you save them to your Downloads folder.
转到下载"文件夹
cd ~/Downloads/
解压缩下载的工具
Unzip the tools you downloaded
unzip tools_r*-macosx.zip
将它们移动到不会意外删除它们的地方
Move them somewhere you won't accidentally delete them
mkdir ~/.android-sdk-macosx
mv tools/ ~/.android-sdk-macosx/tools
运行SDK Manager
Run the SDK Manager
sh ~/.android-sdk-macosx/tools/android
取消选中除Android SDK Platform-tools
(可选)
- 单击
Install Packages
,接受许可证,然后单击Install
.关闭"SDK管理器"窗口.
- Click
Install Packages
, accept licenses, clickInstall
. Close the SDK Manager window.
-
将
platform-tools
添加到您的路径
echo 'export PATH=$PATH:~/.android-sdk-macosx/platform-tools/' >> ~/.bash_profile
刷新您的bash个人资料(或重新启动您的终端应用)
Refresh your bash profile (or restart your terminal app)
source ~/.bash_profile
开始使用adb
Start using adb
adb devices
这篇关于在macOS上安装ADB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!