mac配置android sdk环境
目前用的mac。
先下载sdk。从官网下载了sdk tool:https://developer.android.com/studio/#downloads。如果连不上就用这个链接:https://developer.android.google.cn/studio?hl=zh-cn(没必要一定下载android studio,当然下载android studio是最简单的方式)
然后解压并运行./tools/bin/sdkmanager. 似乎我的电脑有问题,运行失败。
然后用了brew。正如stackoverflow上这个链接里说的:https://stackoverflow.com/questions/2677431/where-to-install-android-sdk-on-mac-os-x。
Now the android-sdk
is migrated from homebrew/core
to caskroom/cask
.
brew tap caskroom/cask # 现在似乎是不需要了
and install android-sdk
using
brew cask install android-sdk
You will have to add the ANDROID_HOME
to profile (.zshrc or .bashrc) 注意路径
export ANDROID_HOME=/usr/local/share/android-sdk
install adb
brew install homebrew/cask/android-platform-tools
另外用avd manager创建了emulator后,也可以用命令行启动它,比如emulator -avd Nexus_9_API_28
如果遇到错误提示‘Cannot find AVD system path. Please define ANDROID_SDK_ROOT’,那么在环境变量中添加一行:
export ANDROID_SDK_ROOT=/Users/bjiang1/Library/Android/sdk/
如果继续遇到错误提示‘PANIC: Missing emulator engine program for 'x86' CPU.’,那么在环境变量中再添加一行:
export PATH=$PATH:$ANDROID_SDK_ROOT/emulator
比如uiautomatorviewer在路径/usr/local/Caskroom/android-sdk/4333796/tools/bin/下或/usr/local/share/android-sdk/tools/bin。
环境变量样例:
test-macbookpro
[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
export PATH="/usr/local/opt/icu4c/bin:$PATH"
export PATH="/usr/local/opt/icu4c/sbin:$PATH"
PATH=$PATH:/Users/bjiang1/workspace/selenium_webdriver
export JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
export ANDROID_HOME=/usr/local/share/android-sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$JAVA_HOME/bin
my-macbookpro
source /Users/bojiang/.rvm/scripts/rvm
PATH=$PATH:/usr/local/mysql/bin
#export PATH=/Users/bojiang/download/WebDriver:$PATH
PATH=$PATH:/Users/bojiang/download/WebDriver
if which pyenv > /dev/null; then eval "$(pyenv init -)"; fi
LDFLAGS=/usr/local/opt/curl/lib
CPPFLAGS=/usr/local/opt/curl/include
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles
export JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
export ANDROID_HOME=/Users/bojiang/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools