将 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
这样我就可以将它们与例如Phonegap.
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
.
通过在终端上发出命令
open ~/.bash_profile
打开你的~/.bash_profile
文件
将以下行添加到该文件的末尾
Add the following lines to the end of that file
导出路径=/Users/$USER/Library/Android/sdk/tools:$PATH
导出路径=/Users/$USER/Library/Android/sdk/tools/bin:$PATH
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