将SDK工具添加到Android Studio应用中的路径

问题描述:

我刚刚安装了Android Studio 0.2.2.我想将SDK工具添加到$PATH(位于此文件夹中):

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.

但是将这个文件夹添加到$PATH之后,它仍然会说:

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

android:找不到命令

android: command not found

奇怪的是,即使我cd到该文件夹​​并键入其名称,我也无法运行该文件夹中的任何可执行文件.

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

我在做什么错了?

似乎新版本的Android Studio并未与SDK捆绑在一起.因此,/Applications/Android\ Studio.app/sdk/tools将不再起作用.

It seems that newer versions of Android Studio don't come bundled with the SDK. So, /Applications/Android\ Studio.app/sdk/tools will no longer work.

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

After launching the SDK Manager from Android Studio, I realized the new path is /Users/$USER/Library/Android/sdk/tools.

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

在该文件的末尾添加以下行

Add the following lines to the end of that file

  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
  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

  • 保存并关闭~/.bash_profile文件

    如果要使更改在当前终端上生效,则source ~/.bash_profile;否则,请关闭并重新打开终端,更改将自动进行

    If you want the changes to take action on the current terminal, then source ~/.bash_profile; otherwise, close and re-open the terminal, and the changes will take place automatically