Skip to content

Instantly share code, notes, and snippets.

@Erichain
Last active October 13, 2024 02:41
Show Gist options
  • Save Erichain/0ac3a6aaca0c28ad6551 to your computer and use it in GitHub Desktop.
Save Erichain/0ac3a6aaca0c28ad6551 to your computer and use it in GitHub Desktop.
Mac OS下安装和配置android-sdk

##MAC OS下安装和配置android-sdk

###安装

在MAC上安装android-sdk,标准的安装方法是使用homebrew,运行如下命令:

brew update

brew install android-sdk

如果遇到无法通过代理下载安装包的情况时,可以先手动下载安装包, 然后,将安装包放到homebrew的缓存里,

$ cp <path to download file> $(brew --cache android-sdk)

再执行

$ brew install android-sdk

这样,就可以成功安装android-sdk了。


###配置

1、配置.bash_profile,如果使用的是Oh-My-Zsh,则配置.zshrc,在文件的结尾加上下面这句:

export ANDROID_HOME="/usr/local/opt/android-sdk"

然后source ~/.zshrc使其生效

2、安装辅助包

运行android命令,调出Android SDK Manager,安装下面这些选项:

  • Tools

    • Android SDK Tools
    • Android SDK Platform-tools
    • Android SDK Build-tools
  • Android 5.1.1 (API 22)

    • SDK Platform
    • Intel x86 Atom_64 System Image
  • Extras

    • Android Suport Library
    • Intel x86 Emulator Accelerator(HAXM Installer)

3、安装HAXM(Hardware_Accelerated_Execution_Manager)

进入以下目录

$ cd /usr/local/Cellar/android-sdk/24.4.1_1/extras/intel/Hardware_Accelerated_Execution_Manager/

然后安装HAXM

$ ./HAXM\ installation

就这样,android模拟器就安装好了。


###配置模拟器

运行以下命令:

$ android avd

  • 打开Android Virtual Device Manager

  • 选择Device Definitions一项

  • 选择需要的模拟器类型,点击Create AVD

创建完成AVD之后,回到Android Virtual Devices选项卡,选择创建好的模拟器,点击Start就可以启动模拟器了。

@EXSVAMP
Copy link

EXSVAMP commented Jun 19, 2017

brew 命令 修改为 brew cask install android-sdk

@tigercandy
Copy link

brew 命令 修改为 brew cask install android-sdk

然后.bash_prodile就要改成export ANDROID_HOME=/usr/local/share/android-sdk

@garasmc
Copy link

garasmc commented Dec 21, 2019

android 无法启动 Android SDK Manager 的 GUI 进行安装的

可使用 tools/bin/sdkmanager --list 列出所有可用包,用命令行手动安装

@Xu-Shuhao
Copy link

我用brew cask install android-sdk 安装完毕之后,./zsh里面会自动添加Android_Home。用Finder在对应的路径下也能找到,但是Android_studio识别不出来!所以,我只能用brew cask uninstall android-sdk卸载后,用Android Studio下载一边,下载到/Users/用户名/Library/Android/sdk 这个目录里面(用户名是你本机的用户名,例如lisa)

@youngjuning
Copy link

说 android studio 太大的,电脑是有多小啊

@miozus
Copy link

miozus commented Apr 26, 2021

~/opt/cmdline-tools/bin
❯ ./sdkmanager
Error: Could not determine SDK root.
Error: Either specify it explicitly with --sdk_root= or move this package into its expected location: <sdk>/cmdline-tools/latest/

~/opt/cmdline-tools/bin 43s
❯ ./sdkmanager --sdk_root=$HOME/Library/Android/sdk

Warning: Failed to download any source lists!
Warning: Still waiting for package manifests to be fetched remotely.
Warning: IO exception while downloading manifest
Warning: Still waiting for package manifests to be fetched remotely.
[=======================================] 100% Computing updates...

.zshrc设置空文件变量仍然报错, 官网放弃命令行更新,各种不友好的文档引导, 下载界面藏底部, 各种逼你装IDE, 网上文档也很少安装成功的(都过时没用),

到底不能干净的安装 Flutter 的安卓环境, 所以我哭了, 把卸载的 IDE 又安装起来. 😭

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment