一直以来想编译android源码,趁闲编译了下,ubuntu版本:20.04,android源码版本:android-9.0.0_r30。总体还比较顺畅,中间遇到了一些报错,在文中也有记录,详情见下文。
sudo apt-get install git-core
sudo apt-get install git-core curl
mkdir ~/bin
PATH=~/bin:$PATH
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
报错换国内的
curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o ~/bin/repo
chmod a+x ~/bin/repo
sudo gedit .bashrc
export REPO_URL=https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/
如:
报错:/usr/bin/env: “python”: 没有那个文件或目录
sudo apt install python2
sudo ln -s /usr/bin/python2 /usr/bin/python
repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest
还是失败
替换路径
将REPO_URL修改国内可访问路径“https://mirrors.tuna.tsinghua.edu.cn/git/git-repo”,如下
REPO_URL = os.environ.get('REPO_URL', None)
if not REPO_URL:
REPO_URL = 'https://gerrit.googlesource.com/git-repo'
修改为https://mirrors.tuna.tsinghua.edu.cn/git/git-repo
再次执行
repo has been initialized in /home/sunnyin 既成功
repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-9.0.0_r30
find . -iname tmp_pack_* | xargs rm
repo sync -j4
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
source build/envsetup.sh
lunch查看编译目标
user:用来正式发布到市场的版本,权限受限,如没有 root 权限,不能 dedug,adb默认处于停用
userdebug:在user版本的基础上开放了 root 权限和 debug 权限,adb默认处于启用状态。一般用于调试真机。
eng:开发工程师的版本,拥有最大的权限(root等),具有额外调试工具的开发配置。一般用于模拟器。
lunch 5
make -j4
报错
prebuilts/clang/host/linux-x86/clang-4691093/bin/clang++.real: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory
解决:
sudo apt-get install libncurses*
启动模拟器
执行emulator
https://blog.csdn.net/a992036795/article/details/53462068
https://mirrors.tuna.tsinghua.edu.cn/help/AOSP/
https://blog.csdn.net/u014078003/article/details/122398618
https://juejin.cn/post/6844903811304325127
https://www.bilibili.com/video/BV15u411o7Ko?spm_id_from=333.337.search-card.all.click