Ubuntu20.04编译安卓aosp 15源码编译到模拟器运行

背景:

aosp15也开始悄悄在各个手机厂商开始酝酿了,感叹时间很快,今天也准备针对aosp15进行一下源码环境的搭建,整体aosp15的搭建和13/14其实没啥大的差别,只不过在lunch目标这个地方确实很大不同,还有就是模拟器启动后的大小不太合适。下面文章将带大家手把手搭建好aosp15/android 15的源码环境,并成功运行起来模拟器,方便大家体验新版本安卓。
看本篇文章建议可以先看如下两篇参考文章:
aosp13/14源码环境搭建:
https://blog.csdn.net/learnframework/article/details/121345533

aosp15上选择目标与aosp14版本的差异分析:
https://mp.weixin.qq.com/s/9xkNgKKxBWlM_qtpLmRL5g

相关库下载:

sudo apt-get install libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-dev
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
sudo apt-get install git-core gnupg flex bison gperf build-essential
sudo apt-get install zip curl zlib1g-dev gcc-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 libncurses5

源码repo下载:

获取具体15版本的分支:
可以先使用如下repo命令(注意这里使用清华大学镜像下载)

repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest 

在这里插入图片描述ps:如果这里会出现啥错误,问题解决方法请参考https://blog.csdn.net/learnframework/article/details/121345533

末尾没有加-b指定分支,这时候repo下来一般是默认主版本的分支,这分支不是我们想要的,那么接下来要去.repo文件夹,看看所有分支情况

cd .repo/manifests
 git branch  -a

查看所有分支结果如下:
在这里插入图片描述明显分支就1-2个,明显没有aosp15分支,这里对当前目录进行git pull操作:

在这里插入图片描述这时候git branch -a发现如下aosp15的最新分支:
在这里插入图片描述
所以这里选定分支为android-15.0.0_r3

repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-15.0.0_r3

编译步骤:

env环境配置:
. build/envsetup.sh
注意这里点后面有空格才是build

选择目标target(注意这里最重要和以前版本最大差异):

lunch sdk_phone64_x86_64-trunk_staging-eng

那么为啥是这个呢?其实是有相关提示的可以
如果只执行命令lunch,输出如下:


You're building on Linux

Warning: Cannot display lunch menu.

Note: You can invoke lunch with an explicit target:

  usage: lunch [target]

Which would you like? [aosp_cf_x86_64_phone-trunk_staging-eng]
Pick from common choices above (e.g. 13) or specify your own (e.g. aosp_barbet-trunk_staging-eng): 

这里就给了我们一个范例aosp_cf_x86_64_phone-trunk_staging-eng这种模式,对我们来说这里可以分为两个部分
第一部分:aosp_cf_x86_64_phone这个是可变的,需要根据我们自己情况选择,具体怎么选稍后说
第二部分:-trunk_staging-eng这里其实可以不需要变化
所以我们就只需要确定第一部分既可以。

那么第一部分的Product是如何确定的,这里怎么就知道是sdk_phone64_x86_64,而不是以前的sdk_phone_x86_64
原因剖析可以原来这个文章:
https://mp.weixin.qq.com/s/9xkNgKKxBWlM_qtpLmRL5g

编译命令:
make

编译成功后运行:
emulator
显示如下:
在这里插入图片描述乍一看相比以前aosp13/14版本来说,感觉这个模拟器的显示大小明显小了很多,看看命令行输出的分辨率和屏幕密度情况:
在这里插入图片描述

明显看到这里分辨率才是480x800难怪显示很小,这里如果要分辨率正常大小可以修改成1080x1920,或者以前13/14版本的1440x2960

修改到合适的显示大小

下面来教大家如何修改分辨率
分辨率这些数据其实都是在对应的config文件中保存的,这里简单起见可以直接去修改out目录下的config.ini文件

out/target/product/emu64x/config.ini

avd.ini.encoding=UTF-8
disk.dataPartition.size=10G
fastboot.forceColdBoot = yes
hw.accelerometer=yes
hw.audioInput=yes
hw.battery=yes
hw.camera.back=emulated
hw.camera.front=emulated
hw.dPad=no
hw.gps=yes
hw.gpu.enabled=yes
hw.keyboard=yes
hw.lcd.density=240
hw.cpu.ncore = 4
hw.mainKeys=no
hw.ramSize = 4096
hw.sensors.orientation=yes
hw.sensors.proximity=yes
image.sysdir.1=x86/
skin.dynamic=no
skin.name=480x800
skin.path=480x800

具体修改点如下:
在这里插入图片描述

在这里插入图片描述
整体上体验了一下,功能上感觉不出有啥差异,动画的体验性相比原来aosp14好像湿滑了不少,其他功能暂时还未深入体验。

猜你喜欢

转载自blog.csdn.net/learnframework/article/details/143086346