赞
踩
虚拟机版本:Vmware16
操作系统版本:Ubuntu16.04
虚拟机内存分配:10GB
虚拟机处理器核:16核
sudo apt-get install libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-dev g++-multilib
sudo apt-get install -y git flex bison gperf build-essential libncurses5-dev:i386
sudo apt-get install tofrodos python-markdown libxml2-utils xsltproc zlib1g-dev:i386
sudo apt-get install dpkg-dev libsdl1.2-dev libesd0-dev
sudo apt-get install git-core gnupg flex bison gperf build-essential
sudo apt-get install zip curl zlib1g-dev gcc-multilib g++-multilib
sudo apt-get install libc6-dev-i386
sudo apt-get install lib32ncurses5-dev x11proto-core-dev libx11-dev
sudo apt-get install libgl1-mesa-dev libxml2-utils xsltproc unzip m4
sudo apt-get install lib32z-dev ccache
sudo apt-get install libssl-dev
sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get update
sudo apt-get install openjdk-8-jdk
java -version #检测jdk安装
1、首先,通过运行以下命令确保您的系统和apt包列表完全更新:
sudo apt-get update -y
sudo apt-get upgrade -y
2、在Ubuntu 18.04上安装Git
sudo apt install git
git --version //查询git版本
3、配置git账号
git config --global user.email “XXX@XXX.com” //配置git邮箱
git config --global user.name “XXX” //配置git用户名
git config --global list //查看当前配置的git用户
1、repo工具需要调用git命令去clone代码,所以要保证git已经配置完成
mkdir ~/bin //创建repo工作目录
PATH=~/bin:$PATH //配置环境变量
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo //修改可执行权限
2、建立Android工作目录
mkdir source
cd source
1、初始化仓库
repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest
注:获取某个版本的源码(例:android-11.0.0_r46)
repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-11.0.0_r46
注:报错或连接超时可以执行如下语句
export REPO_URL=‘https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/’
2、获取代码
repo sync \同步源码树
若同步一直失败可以切换源为清华源
修改路径为:/etc/apt/source.list
内容修改为如下:
默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
#deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
#deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
#deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
#deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
#预发布软件源,不建议启用
#deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
在下面网址中找到对应的驱动版本
链接: https://developers.google.com/android/drivers#bluelinerq3a.211001.001
下载地址参考:
链接: https://blog.csdn.net/qq_40340448/article/details/124502496
需要注意的是下载的文件有两个(google对应的vendor和Qualcomm对应的驱动)
下载好Build ID对应的驱动之后解压生成对应的脚本文件,将其复制到Android源码路径下执行,执行成功之后生成vendor文件夹。(注意,执行过程中最后需要输入I ACCEPT)
$ source build/envsetup.sh //加载环境变量
$ make clobber //清理out目录下编译生成的文件
#根据列表序号选择具体内容
#基于pixel编译则选择3
#如果是虚拟机可以选择aosp_x86_64-eng
$ lunch
#或也可以直接选择
$ lunch aosp_blueline-userdebug
#或也可以直接选择序号
$ lunch 3
#开始编译系统
#根据 cpu 的核数来,核数越多编译越快
$ make -j8 >&1 | tee build_log.txt
解决方案:
1、修改build/soong/java/config/config.go内容
pctx.StaticVariable(“JavacHeapSize”, “2048M”) -> pctx.StaticVariable(“JavacHeapSize”, “1024M”)
2、修改build/soong/java/config/makevars.go内容
ctx.Strict(“DX_COMMAND”, " D8Cmd-JXms16M-JXmx2048M") -> ctx.Strict(“DX_COMMAND”,"D8Cmd-JXms16M-JXmx1024M”)
3、修改build/soong/java/droiddoc.go内容,设置metalava的堆大小
cmd.BuiltTool(ctx, “metalava”).
Flag(config.JavacVmFlags).
Flag(“-J-Xmx3112m”). //增加这一句
FlagWithArg("-encoding “, “UTF-8”).
FlagWithArg(”-source ", javaVersion.String()).
1、首先使用free -m查看当前空间:
$ free -m
total used free shared buff/cache available
Mem: 32097 915 1955 8221 29226 22464
Swap: 975 0 975
2、创建一个目录用作交换分区(扩大到32G)
$ mkdir swapfile
$ cd swapfile/
$ sudo dd if=/dev/zero of=swap bs=1024 count=32000000
3、把生成的文件转换成swap文件
$ sudo mkswap -f swap
4、激活swap文件
$ sudo swapon swap
激活之后使用free -m查询swap空间是否增大
5、一直保持该swap
将如下语句添加到/etc/fstab文件
$ sudo gedit /etc/fstab
语句:/home/green/swapfile/swap swap swap defaults 0 0
su root
vim ~/.bashrc
export ADB=/home/zhangbin/Android/Sdk/platform-tools
export PATH=
A
D
B
:
ADB:
ADB:PATH
:wq 保存退出
source ~/.bashrc
adb version 确认配置的目录和显示的一致
fastboot --version
export ANDROID_PRODUCT_OUT=/home/zhangbin/Aosp/out/target/product/sailfish
cd Aosp/out/target/product/sailfish
fastboot flashall -w
1: https://blog.csdn.net/qq_40340448/article/details/124502496
2: https://blog.csdn.net/qq_41285455/article/details/123629834
3: https://blog.csdn.net/nei504293736/article/details/109628378
4: http://t.zoukankan.com/juexin-p-13600197.html
5: http://t.zoukankan.com/Jaguar-p-10724143.html
6: https://blog.csdn.net/xiaopangcame/article/details/124786527
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。