part01_搭建ubuntu14.04与Android源码级开发环境

一、前言

  • 参考 Android源码开发者网站 搭建AOSP环境

二、搭建源码开发环境

1.下载安装虚拟机和ubuntu14.04 镜像

下载并安装虚拟机,配置虚拟机内存8192M,150G磁盘空间,导入ubuntu14.04 镜像,启动虚拟机.

  • VMware虚拟机下载

  • Ubuntu 14.04.5 Desktop (64-bit) 种子下载

2.安装openjdk
  • 查看源

     $ sudo gedit /etc/apt/sources.list
    
  • 修改源,将sources.list里面的内容全部替换为以下内容

      deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
      deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
      deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
      deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
      deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
      deb-src  http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
      deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
      deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
      deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
      deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
    

  • 更新源

    $ sudo apt-get update
    
  • 安装openjdk-7-jdk

    $ sudo apt-get install openjdk-7-jdk
    
3. 安装所需软件包
  $  sudo apt-get install 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 libgl1-mesa-dev libxml2-utils xsltproc unzip
4. 配置USB权限
  $  wget -S -O - http://source.android.com/source/51-android.rules | sed "s//$USER/" | sudo tee >/dev/null /etc/udev/rules.d/51-android.rules; sudo udevadm control --reload-rules
  • 列出USB设备 查看厂商编码

    $  lsusb 
    

三、下载源码

1.创建目录
$ mkdir bin
$ mkdir -p AOSP/android6.0
2.下载repo工具
$ curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo > ~/bin/repo
$ chmod a+x bin/repo
3.配置Git
$ cd  AOSP/android6.0
$ git config --global user.name "YourName"
$ git config --global user.email "[email protected]"
4.初始化repo
  • 1.编辑bashrc文件

    $ vi ~/.bashrc
    
  • 2.末尾插入配置

    PATH=~/bin:$PATH
    export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/'
    
  • 3.退出重新打开

    $ exit
    $ cd AOSP/android6.0/
    
  • 4.执行repo初始化

    repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-6.0.1_r78
    
5.下载代码
   $ repo sync
part01_搭建ubuntu14.04与Android源码级开发环境_第1张图片
下载完成
part01_搭建ubuntu14.04与Android源码级开发环境_第2张图片
源码目录

本人10M/s下载速度花费了3小时左右的时间

四、校验源码

1.导入公钥
   $ cd /AOSP/android6.0/build/
   $ gpg --import

公钥如下

-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.2.2 (GNU/Linux)

mQGiBEnnWD4RBACt9/h4v9xnnGDou13y3dvOx6/t43LPPIxeJ8eX9WB+8LLuROSV
lFhpHawsVAcFlmi7f7jdSRF+OvtZL9ShPKdLfwBJMNkU66/TZmPewS4m782ndtw7
8tR1cXb197Ob8kOfQB3A9yk2XZ4ei4ZC3i6wVdqHLRxABdncwu5hOF9KXwCgkxMD
u4PVgChaAJzTYJ1EG+UYBIUEAJmfearb0qRAN7dEoff0FeXsEaUA6U90sEoVks0Z
wNj96SA8BL+a1OoEUUfpMhiHyLuQSftxisJxTh+2QclzDviDyaTrkANjdYY7p2cq
/HMdOY7LJlHaqtXmZxXjjtw5Uc2QG8UY8aziU3IE9nTjSwCXeJnuyvoizl9/I1S5
jU5SA/9WwIps4SC84ielIXiGWEqq6i6/sk4I9q1YemZF2XVVKnmI1F4iCMtNKsR4
MGSa1gA8s4iQbsKNWPgp7M3a51JCVCu6l/8zTpA+uUG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lJZlACgkWF7wi2YLW3Oa+jv2QSTlrx4KLM=
=Wi5D
-----END PGP PUBLIC KEY BLOCK-----
2.输入完公钥之后不要执行回车等其他操作,直接执行Ctrl+D
3.查看所有版本,找到自己下载的版本号
$ git tag 
4.校验,签名输出的信息一致说明代码完整并没有被篡改!
$ git tag -v android-6.0.1_r78
part01_搭建ubuntu14.04与Android源码级开发环境_第3张图片
校验完整性

至此源码下载完毕!

你可能感兴趣的:(part01_搭建ubuntu14.04与Android源码级开发环境)