前提:本机已安装配置好JDK。
若未安装JDK,请参考下文:
1.《Ubuntu16.04一键安装jdk》进行操作
1.一键安装 android sdk
#!/bin/bash
#this shell to use installing android_sdk
echo "this shell to use installing android_sdk"
echo "------------------start to install android_sdk----------------------"
#sudo su #切换到root权限
cd /opt
#download android_sdk
wget https://dl.google.com/android/android-sdk_r24.4.1-linux.tgz
#extract android_sdk
tar -zxvf android-sdk_r24.4.1-linux.tgz
#set environment
export ANDROID_HOME="/opt/android-sdk-linux"
if ! grep "ANDROID_HOME=/opt/android-sdk-linux" /etc/profile
then
echo "ANDROID_HOME=/opt/android-sdk-linux" | sudo tee -a /etc/profile
echo "export ANDROID_HOME" | sudo tee -a /etc/profile
echo "PATH=${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools:$PATH" | sudo tee -a /etc/profile
echo "export PATH" | sudo tee -a /etc/profile
fi
#update profile
source /etc/profile
sudo update-alternatives --install /usr/bin/android android /opt/android-sdk-linux/tools/android 360
sudo update-alternatives --install /usr/bin/adb adb /opt/android-sdk-linux/platform-tools/adb 361
#----------------------------------------------------
#自行安装选择安装需要的API版本[适用于windows与linux;macox没有试过]
#[android update sdk --no-ui]更新下载最新的sdk
#[android update sdk --no-ui --all ]更新下载最新的所有sdk
echo "自行安装选择安装需要的API版本"
echo "install api21---android5.0.2"
#install api21---android5.0.2
#android update sdk --no-ui -u --all --filter platform-tools,android-21
sudo android update sdk --no-ui --all --filter platform-tools,android-22
#----------------------------------------------------
#验证adb是否可用
adb version
echo "#----------------------over----------"