Android源码编译

Android源码编译

编译设备系统

18.04LTS—-22.04LTS

远程控制

1
sudo apt install openssh-server openssl

源码拉取工具

1
sudo apt install curl repo git wget

git ssh配置

1
2
3
4
5
6
7
8
9
git config --global user.name "Your.Name"
git config --global user.email "Your.Email"
git config --global i18n.commitencoding utf-8
git config --global i18n.logoutputencoding utf-8
export LESSCHARSET=utf-8
git config --global http.postBuffer 524288000
git config --global https.postBuffer 524288000
git config --global http.lowSpeedLimit 0
git config --global http.lowSpeedTime 999999

将python映射到默认

1
sudo ln -s /usr/bin/python3 /usr/bin/python

原生编译依赖库

1
sudo apt install git-core gnupg flex bison build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 libncurses5 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev libxml2-utils xsltproc unzip fontconfig lib32z-dev ccache default-jdk

高通源码依赖编译库

1
sudo apt install libx11-dev libreadline-dev libgl1-mesa-dev g++-multilib git flex bison gperf build-essential libncurses-dev tofrodos python3-markdown libxml2-utils xsltproc zlib1g-dev dpkg-dev libsdl1.2-dev gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev libgl1-mesa-dev libxml2-utils xsltproc unzip m4 lib32z1-dev ccache libssl-dev

关闭系统默认的oom进程

1
2
sudo systemctl disable systemd-oom.service
sudo systemctl stop systemd-oom.service

拉取源码

1
2
3
4
5
6
7
8
9
10
11
12
curl -OC - https://mirrors.tuna.tsinghua.edu.cn/aosp-monthly/aosp-latest.tar # 下载初始化包
tar xf aosp-latest.tar
# 解压得到的 AOSP 工程目录
cd AOSP
# 这时 ls 的话什么也看不到,因为只有一个隐藏的 .repo 目录
repo sync
# 正常同步一遍即可得到完整目录
# 或 repo sync -l 仅checkout代码
# 初始化仓库
repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest
# 指定某个版本初始化仓库
repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-4.0.1_r1

详情参考:清华AOSP

开始编译

1
2
3
4
5
6
7
8
cd aosp
source build/envsetup.sh
# 查看需要编译的类型 lunch
lunch sdk_car_x86_64-userdebug
# make 不加参数也可以
make -j8
# 在模拟器中运行
emulator -writable-system

单独编译

1
2
3
source build/envsetup.sh
lunch sdk_car_x86_64-userdebug
make CarMapsPlaceholder -j16

推自己的apk

1
2
3
4
5
6
7
8
adb root
adb remount
adb reboot

adb root
adb remount
adb push out/target/product/emulator_car_x86_64/system/app/CarMapsPlaceholder/CarMapsPlaceholder.apk /system/app/CarMapsPlaceholder/

安装所需开发工具软件
根据开发需要和个人习惯安装一些工具软件,只列出一些通用的,默认系统没有安装的软件:

1)vim-gtk
带UI的vim,在图形界面下使用方便一点,不用专门开一个终端。

$ sudo apt install vim-gtk
1
2)vs code
主页:https://code.visualstudio.com/
Ubuntu上dep安装包下载连接:https://code.visualstudio.com/sha/download?build=stable&os=linux-deb-x64
我下载的版本是:code_1.75.0-1675266613_amd64.deb
使用dpkg命令安装:

sudo dpkg -i code_1.75.0-1675266613_amd64.deb
1
安装后选装需要的extension或者通过登录微软账号自动同步vs code配置。

3)google chrome (或者chromium)
(1) install chrome browser by wget
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome-stable_current_amd64.deb

(2) install chrome browser by ppa
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add
wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo sh -c ‘echo “deb http://dl.google.com/linux/chrome/deb/ stable main” >> /etc/apt/sources.list.d/google-chrome.list’
sudo apt update
sudo apt install google-chrome

(3) install chromium browser (chromium is open source and can not login google account or sync data)
sudo apt install chromium-browser

4)搜狗输入法,sogou pinyin
(1) download: https://shurufa.sogou.com/linux
(2) Ubuntu安装搜狗输入法

sudo apt-get install fcitx libgsettings-qt1 libqt5qml5 libqt5quick5 libqt5quickwidgets5 qml-module-qtquick2
sudo apt -f install

sudo apt purge ibus

设置fcitx开机自启动
在终端执行sudo cp /usr/share/applications/fcitx.desktop /etc/xdg/autostart/

5)android studio, sdk, ndk
(1) android studio
https://developer.android.google.cn/studio/
https://developer.android.google.cn/studio/preview

(2) ndk
https://developer.android.google.cn/ndk/downloads

6)WPS
https://linux.wps.cn/
https://wps-linux-personal.wpscdn.cn/wps/download/ep/Linux2019/11698/wps-office_11.1.0.11698_amd64.deb
sudo dpkg -i wps-office_11.1.0.11698_amd64.deb

7)WindTerm(或者terminator)
WindTerm download
https://master.dl.sourceforge.net/project/windterm.mirror/2.5.0/WindTerm_2.5.0_Linux_Portable_x86_64.tar.gz?viasf=1

sudo apt install terminator

8)docker
9)Clion
(1) Clion
https://www.jetbrains.com.cn/en-us/clion/download/#section=linux
(2) IntelliJ IDEA Ultimate
https://www.jetbrains.com.cn/idea/download/?section=linux
(3) goland
https://www.jetbrains.com.cn/en-us/go/download/#section=linux
(4) pycharm
https://www.jetbrains.com.cn/en-us/pycharm/download/?section=linux

10)minicom
sudo apt install minicom

minicom安装、配置和使用

dingtalk:
https://page.dingtalk.com/wow/z/dingtalk/simple/ddhomedownload#/

lvm
sudo apt install lvm2


转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。可以在下面评论区评论,也可以邮件至 nathanwriting@126.com

文章标题:Android源码编译

字数:992

本文作者:Nathaniel

发布时间:2023-11-17, 21:08:05

最后更新:2023-11-17, 22:04:15

原始链接:http://example.com/2023/11/17/android-aosp-make-md/

版权声明: "署名-非商用-相同方式共享 4.0" 转载请保留原文链接及作者。

×

喜欢就点赞,疼爱就打赏