Ubuntu16.04 搭建Android O以后的编译环境

1. 在如下文件中添加以下源:/etc/apt/sources.list,这样在后续安装插件的时候就不会导致因为源的问题而下载或更新失败,甚是郁闷的情况就会少发生不少

deb http://apt.sys.srv/ubuntu/ trusty main restricted universe multiverse
deb http://apt.sys.srv/ubuntu/ trusty-security main restricted universe multiverse
deb http://apt.sys.srv/ubuntu/ trusty-updates main restricted universe multiverse
deb http://apt.sys.srv/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://apt.sys.srv/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://apt.sys.srv/ubuntu/ trusty main restricted universe multiverse
deb-src http://apt.sys.srv/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://apt.sys.srv/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://apt.sys.srv/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://apt.sys.srv/ubuntu/ trusty-backports main restricted universe multiverse

2. 执行如下的指令

sudo add-apt-repository ppa:ubuntu-toolchain-r/test

sudo add-apt-repository ppa:openjdk-r/ppa

sudo apt-get install gcc-4.9 g++-4.9 cpp-4.9

sudo apt-get install openjdk-8-jdk

sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev libc6-dev lib32ncurses5-dev lib32z1 lib32ncurses5 lib32bz2-1.0 x11proto-core-dev libx11-dev lib32readline-gplv2-dev lib32z-dev libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils xsltproc libssl-dev libxml-parser-perl phablet-tools

  

3. 如果以上的操作执行完,还是编译不过,   可以执行如下的脚本  ,

#!/bin/bash -ex
#execute with user root
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH

cd /etc/apt/
mv sources.list sources.list.bak
echo "deb http://apt.sys.srv/ubuntu/ trusty main restricted universe multiverse
deb http://apt.sys.srv/ubuntu/ trusty-security main restricted universe multiverse
deb http://apt.sys.srv/ubuntu/ trusty-updates main restricted universe multiverse
deb http://apt.sys.srv/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://apt.sys.srv/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://apt.sys.srv/ubuntu/ trusty main restricted universe multiverse
deb-src http://apt.sys.srv/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://apt.sys.srv/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://apt.sys.srv/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://apt.sys.srv/ubuntu/ trusty-backports main restricted universe multiverse" > sources.list

apt-get update
wget builder.pt.xiaomi.com/download/openjdk-8-jre-headless_8u45-b14-1_amd64.deb
wget builder.pt.xiaomi.com/download/openjdk-8-jre_8u45-b14-1_amd64.deb
wget builder.pt.xiaomi.com/download/openjdk-8-jdk_8u45-b14-1_amd64.deb
dpkg -i openjdk-8-jre-headless_8u45-b14-1_amd64.deb || true
apt-get -f install -y
dpkg -i openjdk-8-jre-headless_8u45-b14-1_amd64.deb
dpkg -i openjdk-8-jre_8u45-b14-1_amd64.deb || true
apt-get -f install -y
dpkg -i openjdk-8-jre_8u45-b14-1_amd64.deb
dpkg -i openjdk-8-jdk_8u45-b14-1_amd64.deb
apt-get install -y git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip
apt-get install -y ruby python-mysqldb mysql-client python-pip bc gawk ntp genisoimage mingw32 tofrodos php5-cli maven
gem install retryit
pip install jenkinsapi
pip install --upgrade jenkinsapi
cd /etc/ssh/ && wget builder.pt.xiaomi.com/download/ssh_config -O ssh_config
mkdir -p /usr/lib/jvm
cd /usr/lib/jvm
wget builder.pt.xiaomi.com/download/java-6-sun.tar.gz
tar -xzvf java-6-sun.tar.gz
wget builder.pt.xiaomi.com/download/java-7-openjdk-amd64.tar.gz
tar -xzvf java-7-openjdk-amd64.tar.gz
mkdir -p /home/work/tmp && chmod 1777 /home/work/tmp && cd / && mv tmp tmp_back && ln -s /home/work/tmp /tmp
cd /etc/cron.daily
wget builder.pt.xiaomi.com/download/ntpdate -O ntpdate
chmod +x ntpdate
mkdir -p /etc/ssl/certs/java
cd /etc/ssl/certs/java
wget builder.pt.xiaomi.com/download/cacerts

# 给游戏中心安装一个依赖的软件,否则ndk编译不过
apt-get install libbz2-dev

# android O开始,需要
# import Crypto.PublicKey.RSA
apt-get install -y python-dev
pip install pycrypto

 

4. Adb 和fastboot工具

https://developer.android.com/studio/releases/platform-tools

下载完以后要将adb 和fastboot放在/home/bin目录下,在.bashrc里添加过PATH=~/bin:$PATH这条命令。此时使用命令:source ~/.bashrc即可更改adb和fastboot版本

之后再:

adb kill-server

adb start-server

# 接下来就可以在linux bash 下边运行adb 命令

adb devices

# List of devices attached

# 86eb9b180804    device

你可能感兴趣的:(linux常用命令和工具)