在Mac上查找Android SDK并将其添加到PATH [英] Finding Android SDK on Mac and adding to PATH
问题描述
我已经在MacBook Air(操作系统版本10.11 El Capitan)上安装了Android Studio,并成功编写了一个小型的"hello,world"应用程序,并安装在设备(Nexus 7)上,并在AVD上运行.我现在要做的就是能够从命令行(而不是Android Studio)构建该应用程序并将其安装在设备上.我正在按照这里的指示进行操作:
I have installed Android Studio on my MacBook Air (OS Version 10.11 El Capitan) and have successfully written a small "hello, world" app and installed on device (Nexus 7) and ran on AVD. All I want to do now is be able to build the app and install it on device from the command line as opposed to Android Studio. I'm following the directions here:
http://developer.android.com/training/basics/firstapp/running-app.html
,相关行是:
确保PATH环境变量中包含Android SDK platform-tools/目录,然后执行:
Make sure the Android SDK platform-tools/ directory is included in your PATH environment variable, then execute:
问题是我在机器上找不到Android SDK!我认为它在那里是因为否则程序将无法编译并通过Android Studio运行?也许这是一个错误的假设?我是Mac的新手(我曾经使用过Windows),所以我不知道搜索Android SDK的最佳方法.所以我的问题:
The problem is I can't find the Android SDK on my machine! I assume it's there because otherwise the program wouldn't compile and run through Android Studio? Perhaps that's a bad assumption? I'm new to Macs (I'm used to Windows) so I don't know the best way to search for the Android SDK. So my questions:
- 如何在计算机上找到Android SDK?还是向自己证明它不存在?
- 如果没有,我该如何安装?
- 如何更改PATH以包括Android SDK?
推荐答案
1.怎么找到
- 打开Android Studio,转到 Android Studio>偏好设置"
- 搜索
sdk
- 与此类似的东西(如您所见,这是一个Windows框)将显示
- Open Android studio, go to Android Studio > Preferences
- Search for
sdk
- Something similar to this (this is a Windows box as you can see) will show
1. How to find it
大多数情况下,您可以看到那里的位置
You can see the location there – most of the time it is:
/Users/<name>/Library/Android/sdk
2.如果没有的话,如何安装
- 转到 Android独立SDK下载页面
- 下载macOS的zip文件
- 将其提取到目录
- Go to Android standalone SDK download page
- Download the zip file for macOS
- Extract it to a directory
2. How to install it, if not there
打开您的终端,通过键入以下内容来在nano中编辑您的~/.bash_profile
文件:
Open your Terminal edit your ~/.bash_profile
file in nano by typing:
nano ~/.bash_profile
如果您使用Zsh,请改为编辑~/.zshrc
.
If you use Zsh, edit ~/.zshrc
instead.
转到文件末尾,然后将目录路径添加到您的$PATH
:
Go to the end of the file and add the directory path to your $PATH
:
export PATH="${HOME}/Library/Android/sdk/tools:${HOME}/Library/Android/sdk/platform-tools:${PATH}"
- 按
Ctrl+X
保存
- 重启终端
- 要查看其是否正常运行,请输入添加目录(例如
adb
)内的任何文件或二进制文件的名称,并验证其是否已打开/执行 - Save it by pressing
Ctrl+X
- Restart the Terminal
- To see if it is working or not, type in the name of any file or binary which are inside the directories that you've added (e.g.
adb
) and verify it is opened/executed
这篇关于在Mac上查找Android SDK并将其添加到PATH的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!