赞
踩
直接进入主题, 从Android 9.0源码下载到编译Android Car Automotive。
1. 楼主使用的环境: Ubuntu 16.04
硬件配置: Intel 4代 i5处理器, 硬盘 1TB, 内存 8GB.
2. 工具配置
Android 使用git管理代码,Android 中有众多代码库, 使用repo工具来集中管理Android 中的所有git库。
(1)下载git工具
sudo apt-get install git
配置git: 配置邮箱地址和用户名
- git config --global user.email "xxx@xx.com"
- git config --global user.name "xxx"
(2)安装curl库:(用来安装repo工具)
sudo apt-get install curl
(3)创建bin目录并且加入到PATH
- mkdir ~/bin
- PATH=~/bin:$PATH
(4)下载repo工具
curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo > ~/bin/repo
添加可执行权限
chmod a+x ~/bin/repo
repo 初始化需要使用到Python2.7。 ubuntu自带
3. 下载源码
使用清华源进行源码下载
(1)更改repo地址
直接在repo工具脚本中修改:替换 Google repo
REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/'
(2) 建立个存放代码的文件夹并且初始化仓库
- mkdir AOSP
-
- cd AOSP
-
- repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-9.0.0_r8
执行完初始化命令后, 会在当前目录下生成一个.repo的掩藏文件.
repo 初始化完成后开始同步代码
repo sync
等待一段时间(几个小时),等待代码 sync完成
4. 编译Android Car Automotive
(1)安装编译所需库,JDK
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 ccache libgl1-mesa-dev libxml2-utils xsltproc unzip
安装openjdk8
- sudo add-apt-repository ppa:openjdk-r/ppa
- sudo apt-get update
- sudo apt-get install openjdk-8-jdk
-
- sudo update-alternatives --config java
- sudo update-alternatives --config javac
(2) 设置编译环境
source build/envsetup.sh
(3)选择编译平台
此处编译Android Car Automotive,选择10. aosp_car_x86_64-userdebug
lunch
(4) 开始编译
make -j8
make -jxx
-j 后的数字是编译使用的线程数
(电脑较弱,只使用2线程编译)
(5)编译完成
(不同配置的电脑,编译时长不一样,楼主小本本编译了11个小时)
5. 编译结束, 接下来启动Android Car Automotive模拟器
注意: 在刚才编译完成的终端上, 直接输入emulator启动模拟器。
如果是新终端, 需要进行如下操作,再启动模拟器
- source build/envsetup.sh
- lunch 10
- emulator
emulator
直接上图
启动过程:
到此,Android Car Automotive编译启动完成。有兴趣的小伙伴可以学习一下Android Car Automotive
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。