在 Mac 上查找 Android SDK 并添加到 PATH [英] Finding Android SDK on Mac and adding to PATH

查看:33
本文介绍了在 Mac 上查找 Android SDK 并添加到 PATH的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已在 MacBook Air(操作系统版本 10.11 El Capitan)上安装了 Android Studio,并成功编写了一个小型hello, world"应用程序并安装在设备(Nexus 7)上并在 AVD 上运行.我现在想要做的就是能够构建应用程序并将其从命令行安装到设备上,而不是 Android Studio.我正在按照此处的说明进行操作:

你可以看到那里的位置——大部分时间是:

/Users//Library/Android/sdk

2.如果没有,如何安装

  • 转至

    3.如何将其添加到路径中

    打开你的终端,在nano中编辑你的~/.bash_profile文件:

    nano ~/.bash_profile

    如果您使用 Zsh,请改为编辑 ~/.zshrc.

    转到文件末尾并将目录路径添加到您的$PATH:

    export PATH="${HOME}/Library/Android/sdk/tools:${HOME}/Library/Android/sdk/platform-tools:${PATH}"

    • Ctrl+X
    • 保存
    • 重启终端
    • 要查看它是否正常工作,请输入您添加的目录中的任何文件或二进制文件的名称(例如 adb)并验证它是否已打开/执行

    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

    and the relevant line is:

    Make sure the Android SDK platform-tools/ directory is included in your PATH environment variable, then execute:

    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:

    1. How do I find Android SDK on my machine? Or prove to myself it's not there?
    2. If it's not there how do I install it?
    3. How do I change PATH to include Android SDK?

    解决方案

    1. How to find it

    • 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

    You can see the location there – most of the time it is:

    /Users/<name>/Library/Android/sdk
    

    2. How to install it, if not there

    3. How to add it to the path

    Open your Terminal edit your ~/.bash_profile file in nano by typing:

    nano ~/.bash_profile
    

    If you use Zsh, edit ~/.zshrc instead.

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

    • 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屋!

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