win10最新下载编译Android源码的简易方法分享(已亲测)
- 准备至少150G的硬盘空间
- win+R 输入control 打开程序与功能-启用或关闭Windows功能
- 勾选“适用于Linux的Windwos子系统”
- 重启电脑
- win 点击设置-开发者选项-勾选“开发人员模式”
- https://docs.microsoft.com/en-us/windows/wsl/install-manual
- 找到Downloading distributions —下载Ubuntu 20.04
- 打开windows powershell 输入netsh winsock reset
- win+R 输入services.msc 启动Windows installer、Windows Update、Cryptographic Services 、 Background Intelligent Transfer Service、LxxManager
- 将下载好的Ubuntu.aapx放入除C盘外的其他盘—解压—双击ubuntu.exe
- (ubuntu的文件目录就是rootfs) (home就是初始目录)
- 等待unbutu安装,大概15分钟,根据提示,输入名字与密码
- 下面就是配置下载编译Android源码的语法
新建一个bin文件夹
mkdir ~/bin
添加到环境变量中
PATH=~/bin:$PATH
增加文件夹访问权限
chmod 777 ~/bin
安装curl
sudo apt install curl
下载repo(一个用来管理aosp的py脚本)
curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o ~/bin/repo
增加文件的执行权限,repo是一个文件,不是文件夹
chmod a+x ~/bin/repo
打开repo这个文件,文件头改为
/usr/bin/env python3
打开bashrc文件,可以直接找到打开,也可以用gedit编辑器打开
gedit ~/.bashrc
往里面末尾添加一行内容
export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo'
让bashrc生效
source ~/.bashrc
安装git
sudo apt install git
配置git
git config --global user.name yourname
git config --global user.email youremail@qq.com
git config --global http.sslverify false
git config --global https.sslverify false
git config --global --list #查看是否配置成功
下载android源码,先创建一个存放android的文件夹,进去,下载对应版本的android源码(我这里下的是android10,用的12个线程下载,下载时间大概30分钟,会卡在99%那里,不要急,等10分钟左右就行,然后会一直updating files:…,大概20分钟)
mkdir -p aosp/android
cd aosp/android
repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-10.0.0_r1
repo sync -j12
安装依赖包
sudo apt-get install git-core gnupg fiex bison build-essential zip curl zlibig-dev gcc-multilib g++-multilib libc6-dev-i386 libncurses5 lib32ncurses5-dev xl1proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev libxml2-utils xsltproc unzip fontconfig
android源码就下载到aos/android文件夹中,可以选择编译整个源码,或者另作它用
编译源码
source build/envsetup.sh
lunch