在 Mac OS X 上设置 ANDROID_HOME 环境变量 [英] Setting ANDROID_HOME enviromental variable on Mac OS X

查看:61
本文介绍了在 Mac OS X 上设置 ANDROID_HOME 环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以发布一个通过终端设置 ANDROID_HOME 的可行解决方案吗?

Could anybody post a working solution for setting ANDROID_HOME via the terminal?

我的 Android-SDK 路径是 /Applications/ADT/sdk.

My path to the Android-SDK is /Applications/ADT/sdk.

推荐答案

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

这篇关于在 Mac OS X 上设置 ANDROID_HOME 环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆