Android系统源码编译环境搭建

Android系统源码:Android 10

编译服务器Linux 系统版本:Linux version 5.4.0-89-generic (buildd@lgw01-amd64-034) (gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)) #100~18.04.1-Ubuntu SMP Wed Sep 29 10:59:42 UTC 2021

java jdk版本:1.8.0_362

python版本:Python 2.7.17

一、Linux修改挂载目录名称(该目录存储空间需要较大,一般是T为单位,例如,我们拿到下面的新服务器,采用data02作为代码存放区)
1、df -h  查找大存储分区

Filesystem      Size  Used Avail Use% Mounted on
udev             32G     0   32G   0% /dev
tmpfs           6.3G  2.1M  6.3G   1% /run
/dev/sda3        49G   12G   36G  24% /
tmpfs            32G     0   32G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs            32G     0   32G   0% /sys/fs/cgroup
/dev/loop0      106M  106M     0 100% /snap/core/16202
/dev/sda4        30G  430M   28G   2% /home
/dev/sda2       189M   79M   96M  46% /boot
/dev/sda5       3.6T  4.0G  3.6T   1% /data
/dev/sdb         18T   18G   18T   1% /data02
tmpfs           6.3G     0  6.3G   0% /run/user/1000

2、解挂
sudo umount /data02

注:如果没有挂载(即通过df -h查看不到),可以通过lsblk查看磁盘后,跳过步骤3,直接执行步骤4

Android系统源码编译环境搭建_第1张图片

3、新建或重命名挂载点目录(AAA为想要改的目标名称)
sudo mv  /data02  /AAA

4、重新挂载设备到挂载点或目录
sudo mount /dev/sdb  /AAA

5、编辑/etc/fastab配置信息
sudo vim /etc/fstab


二、创建用户
1、创建新用户
sudo useradd zhangsan
2、修改用户密码
sudo passwd zhangsan
3、如果需要为新用户分配目录,可以使用以下命令:
sudo mkdir /home/zhangsan
sudo chown zhangsan:zhangsan -R /home/zhangsan
或者软连接方式(AAA目录创建好用户名目录,软连接到home/username目录)
sudo ln -s /AAA/zhangsan  zhangsan

4、新用户登录出现timeout in locking authority file /home/zhangsan/.Xauthority 问题
错误原因是添加用户时没有授权对应的目录,仅仅执行了useradd user而没有授权对应的家目录
直接将用户目录的用户和组设为该用户
sudo chown zhangsan:zhangsan  /home/zhangsan


5、xshell连接Ubuntu登录后不显示用户名
只显示"$“符号,回退键会变为”^H",tab键直接空格时,解决办法:
a.执行命令 sudo -s
b.切换到root帐户下,然后再用命令:vim /etc/passwd
c.点击i(进入插入模式)
d.找对对应的用户名 一行,将最后的 /bin/sh 修改为/bin/bash
e.按esc,键入(:wq),保存退出


三、更新软件前期准备
1、软件源
建议使用清华开源镜像或者阿里云开源镜像,替换前先备份原始文件
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
2、根据需要卸载Libreoffice
sudo apt-get remove --purge libreoffice*
3、更新软件及工具且卸载过时的软件工具

sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get autoremove

四、编译环境搭建
1、安装基本工具
sudo apt-get install \
samba samba-common system-config-samba \
tree vim openssh-server

2、安装SDK编译依赖工具
(1)、Ubuntu14.04LTS(适合用于Ubuntu14版本)

sudo apt-get install \
make gcc g++ gksu patch texinfo libncurses-dev git-core gnupg \
flex bison gperf libsdl-dev libesd0-dev zip ncurses-dev \
zlib1g-dev zlib1g-dev:i386 valgrind libgtk2.0-0:i386 libpangox-1.0-0:i386 \
libpangoxft-1.0-0:i386 libidn11:i386 gstreamer0.10-pulseaudio:i386 \
gstreamer0.10-plugins-base:i386 gstreamer0.10-plugins-good:i386 libxml2-utils \
xsltproc g++-multilib gcc-multilib git python-networkx build-essential curl \
libc6-dev libncurses5-dev libncurses5-dev:i386 x11proto-core-dev libx11-dev:i386 \
libreadline6-dev:i386 libgl1-mesa-dev:i386 mingw32 openjdk-6-jdk tofrodos \
python-markdownxsltproc libxext-dev:i386 subversion gawk cryptsetup cmake gettext \
libssl-dev unzip dosfstools  device-tree-compiler dh-autoreconf libudev-dev \
libusb-dev libusb-1.0-0-dev u-boot-tools

(2)、Ubuntu18.04LTS(适合用于Ubuntu18版本)
 

sudo apt-get install bison build-essential cmake cryptsetup curl device-tree-compiler
sudo apt-get install dh-autoreconf dosfstools flex g++ g++-multilib gawk gcc gcc-multilib
sudo apt-get install gettext git gnupg gperf intltool lib32ncurses5 lib32ncurses5-dev 
sudo apt-get install lib32readline-dev lib32z1 lib32z1-dev libc6-dev libgl1-mesa-dev 
sudo apt-get install libglib2.0-dev liblz4-tool libncurses5-dev libncurses5-dev libsdl1.2-dev 
sudo apt-get install libssl-dev libswitch-perl libudev-dev libusb-1.0-0-dev libusb-dev 
sudo apt-get install libx11-dev libxml2-utils make net-tools net-tools openjdk-8-jdk patch 
sudo apt-get install pkg-config python-markdown python-networkx sl subversion texinfo tofrodos 
sudo apt-get install u-boot-tools unzip valgrind x11proto-core-dev xsltproc zip zlib1g-dev 
sudo apt-get install libgl1-mesa-dev:i386 libgtk2.0-0:i386 libidn11:i386 libncurses5-dev:i386 
sudo apt-get install libpangox-1.0-0:i386 libpangoxft-1.0-0:i386 libx11-dev:i386 libxext-dev:i386 zlib1g-dev:i386

make_ext4fs镜像制作工具安装,没装这个工具,out/dist/recoveryimage.img目录下将没法生成这个镜像
sudo apt install android-sdk-ext4-utils

3、配置samba
(1)、添加samba用户
sudo smbpasswd -a newuser
(2)、sudo vim /etc/samba/smb.conf
(3)、添加以下配置信息:

[newuser]
    comment = newuser Drivers
    path = /home/newuser
    browseable = yes
    valid users = newuser
    writable = yes

4、如果是编译虚拟化代码,用的是docker的话,需要安装docker

sudo apt install -y docker.io

验证java和python环境是否安装成功命令:

java -version
python --version

五、编译问题处理
1、Can't locate XML/Simple.pm in @INC (you may need to install the XML::Simple module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.26.1 /usr/local/share/perl/5.26.1 /usr/lib/x86_64-linux-gnu/perl5/5.26 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.26 /usr/share/perl/5.26 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at vendor/qcom/proprietary/chi-cdk/tools/usecaseconverter/usecaseconverter.pl line 10.
BEGIN failed--compilation aborted at vendor/qcom/proprietary/chi-cdk/tools/usecaseconverter/usecaseconverter.pl line 10.

上述的报错表示XML/Simple.pm出现问题,或者忘记安装了。
需要重新安装XML::Simple module。

sudo cpan install XML::Simple
sudo apt-get install libxml-simple-perl

发现装了这个后,也报错了,对比之前的服务器,发现是没有 /usr/local/share/perl/5.26.1/XML/Simple.pm 文件的,错误如下:

No update in common settings( vendor/qcom/proprietary/camx/src/settings/common/camxsettings.xml ) and target settings( vendor/qcom/proprietary/camx/src/settings/common/camxsettings.xml ): Skip generating composed settings( vendor/qcom/proprietary/camx/src/settings/g_camxsettings.xml ).

Unrecognized character \x88; marked by <-- HERE after <-- HERE near column 1 at /usr/local/share/perl/5.26.1/XML/Simple.pm line 1.
Compilation failed in require at vendor/qcom/proprietary/camx/build/infrastructure/android/../tools/settingsgenerator/settingsgenerator.pl line 27.
BEGIN failed--compilation aborted at vendor/qcom/proprietary/camx/build/infrastructure/android/../tools/settingsgenerator/settingsgenerator.pl line 27.


Unrecognized character \x88; marked by <-- HERE after <-- HERE near column 1 at /usr/local/share/perl/5.26.1/XML/Simple.pm line 1.
Compilation failed in require at vendor/qcom/proprietary/camx/build/infrastructure/android/../tools/props.pl line 13.
BEGIN failed--compilation aborted at vendor/qcom/proprietary/camx/build/infrastructure/android/../tools/props.pl line 13.

Unrecognized character \x88; marked by <-- HERE after <-- HERE near column 1 at /usr/local/share/perl/5.26.1/XML/Simple.pm line 1.
Compilation failed in require at vendor/qcom/proprietary/camx/src/mapperutils/extformatutil/headerfilegen.pl line 10.
BEGIN failed--compilation aborted at vendor/qcom/proprietary/camx/src/mapperutils/extformatutil/headerfilegen.pl line 10.

[ 92% 1803/1941] including vendor/qcom/proprietary/chi-cdk/Android.mk ...
FAILED: 
Generating camx supplementary makefiles.
Generating makefiles for the auto-generated code. ( 1/4 ) Build g_fd_mk ...  Done ( 2/4 ) Build g_sensor_mk ...  Done ( 3/4 ) Build g_chromatix_mk ...  Done ( 4/4 ) Build g_parser_mk ...  Done  Generating auto-generated code. ( 1/4 ) Build ChromatixXSD ...  Done ( 2/4 ) Build ParserUtils ...  Done ( 3/4 ) Build FaceDetection ...  Done ( 4/4 ) Build SensorXSD ...  Done  

Failed to find an xml file for target msmnile. Defaulting to Default blm.xml
python vendor/qcom/proprietary/chi-cdk/tools/blmconfig/blmconfigparser.py -i vendor/qcom/proprietary/chi-cdk/oem/qcom/blm/default/blm.xml -o vendor/qcom/proprietary/chi-cdk/core/chiutils

Unrecognized character \x88; marked by <-- HERE after <-- HERE near column 1 at /usr/local/share/perl/5.26.1/XML/Simple.pm line 1.
Compilation failed in require at vendor/qcom/proprietary/chi-cdk/tools/usecaseconverter/usecaseconverter.pl line 10.
BEGIN failed--compilation aborted at vendor/qcom/proprietary/chi-cdk/tools/usecaseconverter/usecaseconverter.pl line 10.
[UsecaseConverterFailure]
vendor/qcom/proprietary/chi-cdk/core/lib/common/build/android/Android.mk:45: error: vendor/qcom/proprietary/chi-cdk/core/lib/common/common/g_pipelines.h was not generated.
17:44:01 ckati failed with: exit status 1

处理方式:rm -rf /usr/local/share/perl/

然后就没报错了,也有可能是不装libxml-simple-perl也可以,因为博主编译服务器有加密软件,也有可能当时是加密软件导致编译不过,后面关掉了加密软件,加密软件会导致源码乱码


2、FAILED: posix_spawn: Exec format error

sudo apt install libdb1-compat tzdata


3、Unable to locate package libgtk2.0-0:i386
sudo apt-get install libgl1-mesa-dev:i386 libgtk2.0-0:i386 libidn11:i386 libncurses5-dev:i386 
sudo apt-get install libpangox-1.0-0:i386 libpangoxft-1.0-0:i386 libx11-dev:i386 libxext-dev:i386 zlib1g-dev:i386
安装这两个库出现上面的错误时,按以下步骤执行
解决办法:
(1).首先尝试update命令
sudo apt-get update

(2).如果不行则执行upgrade
sudo apt-get upgrade

(3).最后上面两项都不行则尝试
sudo apt-get install aptitude

成功以后使用

sudo aptitude install xxxxx

备注:编译环境需要配置jdk、python环境,有些代码编译依赖于python版本,博主有些源码是依赖python3有些是依赖python

修改编译服务器python版本方法可查阅(推荐使用用户级):Linux环境编译服务器中修改python版本方式_linux服务器更改python版本-CSDN博客

你可能感兴趣的:(Android系统,android)