[原创]编译android10 for pixel
2020-07-19 本文已影响0人
seekting
编译的操作系统
ubuntu 16.04
源码分支获取
找好源码分支
这里我们找pixel因为手里只有pixel
https://source.android.com/setup/start/build-numbers#source-code-tags-and-builds
下载android源码
repo
sudo apt-get install git-core
sudo apt-get install git-core curl
mkdir ~/bin/
cd ~/bin
curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo > ~/bin/repo
chmod a+x ~/bin/repo
gedit ~/.bashrc
在~/.bashrc里添加
alias ob='gedit ~/.bashrc'
alias sr='source ~/.bashrc'
#国内镜像
export REPO_URL='https://aosp.tuna.tsinghua.edu.cn/git-repo'
下载
cd ~/work/sources/android-10.0.0_r17
repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-10.0.0_r17
repo sync -j16
驱动
https://developers.google.com/android/drivers#sailfishqp1a.190711.020
google_devices-sailfish-qp1a.191005.007.a3-a1615a0f.tgz
qcom-sailfish-qp1a.191005.007.a3-191228fe.tgz
解压驱动到vendor文件夹,然后把它放到源码根目录
编译环境
sudo apt-get install git-core gnupg flex bison gperf build-essential \
zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 \
lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache \
libgl1-mesa-dev libxml2-utils xsltproc unzip
sudo apt-get install openjdk-8-jdk
关odex
更改 build/make/core/board_config.mk
#ifeq ($(HOST_OS),linux)
# WITH_DEXPREOPT := true
#endif
WITH_DEXPREOPT=false
修改build/core/dex_preopt_config.mk
DEX_PREOPT_DEFAULT ?= true改成
DEX_PREOPT_DEFAULT?= false
ifneq (true,$(WITH_DEXPREOPT))
ifneq (true,$(WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY))
#$(call pretty-error, DEXPREOPT must be enabled for user and userdebug builds)
$(warning odex关闭)
endif
endif
去掉DEX优化编译的方法:
1、mm WITH_DEXPREOPT=false
2、Android.mk中增加:LOCAL_DEX_PREOPT := false
# Non eng linux builds must have preopt enabled so that system server doesn't run as interpreter
# only. b/74209329
ifeq (,$(filter eng, $(TARGET_BUILD_VARIANT)))
ifneq (true,$(WITH_DEXPREOPT))
ifneq (true,$(WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY))
#$(call pretty-error, DEXPREOPT must be enabled for user and userdebug builds)
$(warning WITH_DEXPREOPT=false)
endif
endif
endif
因为默认eng编译,WITH_DEXPREOPT必须打开为true,否则提示编译报错。
修改android.bp实现模块编译关odex
系统里的打包配置是android.bp,不知道android.mk是怎么转的bp可以看 build/soong/androidmk/cmd/androidmk/android.go
"LOCAL_DEX_PREOPT": "dex_preopt.enabled",
"LOCAL_MODULE": "name",
所以可以去/framework里找android.bp
framework的bp文件在framework/base/Android.bp,加上dex_preopt项
java_library {
name: "framework",
defaults: ["framework-defaults"],
javac_shard_size: 150,
dex_preopt: {
enabled:false,
},
}
services在framework/base/services/Android.bp
java_library {
name: "services",
installable: true,
dex_preopt: {
enabled:false,
//app_image: true,
//profile: "art-profile",
},
准备
source ./build/envsetup.sh
lunch aosp_sailfish-userdebug
编译
make -j16
ninja快速编译framewrk
./prebuilts/build-tools/linux-x86/bin/ninja -f out/combined-aosp_sailfish.ninja services
./prebuilts/build-tools/linux-x86/bin/ninja -f out/combined-aosp_sailfish.ninja framework
adb push out/target/product/sailfish/system/framework/oat/arm64/services.odex system/framework/oat/arm64
adb push out/target/product/sailfish/system/framework/oat/arm64/services.vdex system/framework/oat/arm64
adb push out/target/product/sailfish/system/framework/services.jar system/framework
adb push out/target/product/sailfish/system/framework/services.jar.prof system/framework
刷机
fastboot flashall -w