且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Mac上查找Android SDK并将其添加到PATH

更新时间:2023-12-02 23:05:10

1.怎么找到

  • 打开Android Studio,转到 Android Studio>偏好设置"
  • 搜索sdk
  • 与此类似的东西(如您所见,这是一个Windows框)将显示
  • 1. How to find it

    • Open Android studio, go to Android Studio > Preferences
    • Search for sdk
    • Something similar to this (this is a Windows box as you can see) will show
    • 大多数情况下,您可以看到那里的位置

      You can see the location there – most of the time it is:

/Users/<name>/Library/Android/sdk

2.如果没有的话,如何安装

  • 转到 Android独立SDK下载页面
  • 下载macOS的zip文件
  • 将其提取到目录
  • 2. How to install it, if not there

    • Go to Android standalone SDK download page
    • Download the zip file for macOS
    • Extract it to a directory
    • 打开您的终端,通过键入以下内容来在nano中编辑您的~/.bash_profile文件:

      Open your Terminal edit your ~/.bash_profile file in nano by typing:

nano ~/.bash_profile

如果您使用Zsh,请改为编辑~/.zshrc.

If you use Zsh, edit ~/.zshrc instead.

转到文件末尾,然后将目录路径添加到您的$PATH:

Go to the end of the file and add the directory path to your $PATH:

export PATH="${HOME}/Library/Android/sdk/tools:${HOME}/Library/Android/sdk/platform-tools:${PATH}"

  • Ctrl+X
  • 保存
  • 重启终端
  • 要查看其是否正常运行,请输入添加目录(例如adb)内的任何文件或二进制文件的名称,并验证其是否已打开/执行
    • Save it by pressing Ctrl+X
    • Restart the Terminal
    • To see if it is working or not, type in the name of any file or binary which are inside the directories that you've added (e.g. adb) and verify it is opened/executed