17

I have just installed Android Studio 0.2.2. I want to add the SDK tools to the $PATH, which are in this folder:

/Applications/Android\ Studio.app/sdk/tools

so that I can use them with e.g. Phonegap.

But after I add this folder to the $PATH, it still keeps saying:

android: command not found

Oddly, I can't run any of the executables in that folder even when I cd to that folder and type their names.

What am I doing wrong?

4

5 回答 5

62

似乎较新版本的 Android Studio 没有与 SDK 捆绑在一起。所以,/Applications/Android\ Studio.app/sdk/tools将不再工作。

从 Android Studio 启动 SDK Manager 后,我意识到新路径是 /Users/$USER/Library/Android/sdk/tools.

脚步

  1. 通过在终端上~/.bash_profile发出命令打开文件open ~/.bash_profile

  2. 将以下行添加到该文件的末尾

    1. export PATH=/Users/$USER/Library/Android/sdk/tools:$PATH
    2. export PATH=/Users/$USER/Library/Android/sdk/tools/bin:$PATH
    3. export PATH=/Users/$USER/Library/Android/sdk/platform-tools:$PATH
  3. 保存并关闭~/.bash_profile文件

  4. 如果您希望更改在当前终端上执行,则source ~/.bash_profile;否则,关闭并重新打开终端,更改将自动发生

于 2015-03-16T17:24:59.773 回答
10

您可以将此文件夹添加到您的 PATH 中.bash_profile(用户主文件夹中的隐藏文件):

export PATH=/Applications/Android\ Studio.app/sdk/tools:$PATH

然后重新打开终端应用程序。

如果您需要一个适用于所有 UI 应用程序的环境,您可以使用.launchd.conf(或/etc/launchd.conf适用于所有用户)。

于 2013-08-09T09:30:22.853 回答
6

把它放在你的~/.profile

# Add the Android SDK tools to $PATH and set $ANDROID_HOME (standard)
ANDROID_HOME="${HOME}/Library/Android/sdk"
if [ -d "${ANDROID_HOME}" ]; then
  PATH="${PATH}:${ANDROID_HOME}/tools"
  PATH="${PATH}:${ANDROID_HOME}/platform-tools"
  ANDROID_BUILD_TOOLS_DIR="${ANDROID_HOME}/build-tools"
  PATH="${PATH}:${ANDROID_BUILD_TOOLS_DIR}/$(ls -1 ${ANDROID_BUILD_TOOLS_DIR} | sort -rn | head -1)"
fi

构建工具与其他工具的不同之处在于它们位于子文件夹中。例如,有build-tools/23.0.3, build-tools/25.0.1, build-tools/25.0.2... 所以这会选择最近的一个。

于 2017-01-04T00:57:31.757 回答
2

You are getting bit by the escape character.

The reason tiziano's answer works for him is because the export command needs that backslash after "Android"

however, you are probably editing /etc/paths. When you put the path in there, you don't need the backslash, just put the lines:

/Applications/Android Studio.app/sdk/tools /Applications/Android Studio.app/sdk/platform-tools

in /etc/paths, and you are good to go.

于 2014-08-24T21:49:33.587 回答
0

对我来说是

~/Development/adt-bundle-mac-x86_64-20130729/sdk
于 2015-06-17T16:33:43.157 回答