且构网

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

在 Mac OS X 上设置 ANDROID_HOME 环境变量

更新时间:2022-05-28 09:10:51

Android-SDK 的安装位置取决于您的安装方式.

Where the Android-SDK is installed depends on how you installed it.

  1. 如果您通过他们的网站下载了 SDK,然后将应用程序拖放到您的应用程序文件夹中,则很可能在这里:

  1. If you downloaded the SDK through their website and then dragged/dropped the Application to your Applications folder, it's most likely here:

/Applications/ADT/sdk(就您的情况而言).

如果您使用 Homebrew (brew cask install android-sdk) 安装了 SDK,则它位于此处:

If you installed the SDK using Homebrew (brew cask install android-sdk), then it's located here:

/usr/local/Caskroom/android-sdk/{YOUR_SDK_VERSION_NUMBER}

如果 SDK 是作为 Android Studio 的一部分自动安装的,那么它位于此处:

If the SDK was installed automatically as part of Android Studio then it's located here:

/Users/{YOUR_USER_NAME}/Library/Android/sdk

知道位置后,打开终端窗口并输入以下内容(将 SDK 的路径更改为您安装的路径):

Once you know the location, open a terminal window and enter the following (changing out the path to the SDK to be however you installed it):

export ANDROID_HOME={YOUR_PATH}

设置好后,需要将其添加到PATH环境变量中:

Once you have this set, you need to add this to the PATH environment variable:

export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

最后通过重新采购 .bash_profile 来应用这些更改:

Lastly apply these changes by re-sourcing .bash_profile:

source ~/.bash_profile

  1. 输入 - echo $ANDROID_HOME 以检查是否设置了家.

echo $ANDROID_HOME