Ubuntu中安装Android SDK

一、安装python-software-properties

apt-get update && apt-get install -y -q python-software-properties software-properties-common && apt-get clean

二、安装Oracle java from PPA

add-apt-repository ppa:webupd8team/java -y

echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections

apt-get update && apt-get -y install oracle-java7-installer && apt-get clean

三、ANDROID STUFF

dpkg --add-architecture i386 && apt-get update && apt-get install -y --force-yes expect ant wget libc6-i386 lib32stdc++6 lib32gcc1 lib32ncurses5 lib32z1 qemu-kvm kmod && apt-get clean

四、安装Android SDK

cd /opt && wget --output-document=android-sdk.tgz --quiet && tar xzf android-sdk.tgz && rm -f android-sdk.tgz

五、配置环境

在/etc/profile文件末尾加上如下代码

export ANDROID_HOME=/opt/android-sdk-linux
export PATH=${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools

source /etc/profile

六、安装sdk elements

新建脚本/opt/tools/android-accept-licenses.sh

#!/usr/bin/expect -f

set timeout 1800
set cmd [lindex $argv 0]
set licenses [lindex $argv 1]

spawn {*}$cmd
expect {
"Do you accept the license '*'*" {
    exp_send "y\r"
    exp_continue
}
eof
}

chmod 755 /opt/tools/android-accept-licenses.sh

在/etc/profile文件末尾加上如下代码

export PATH=$PATH:/opt/tools

echo ANDROID_HOME="${ANDROID_HOME}" >> /etc/environment

运行脚本并更新

/opt/tools/android-accept-licenses.sh

android update sdk --all --no-ui --filter platform-tools,tools,build-tools23,android-23,addon-google_apis_x86-google-23,extra-android-support,extra-android-m2repository,extra-google-m2repository,sys-img-x86-android-23 --proxy-host mirrors.neusoft.edu.cn --proxy-port 80 -s

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/14696.html