lineageOS-14.1-oneplus3t-build.md
lineageOS-14(android7)的开发者模式/usb调试(adb)有root功能, 而lineageOS-16(android9)无
oneplus3t-lineage-14编译-android7
1
清华linageos镜像
x
lineage-14.1-20180223-nightly-oneplus3-signed.zip
ntfs分区挂载为普通用户目录 , ext4分区挂载为普通用户目录
bfsu/lineageOS镜像
ts/lingeageOS镜像
oneplus3/lineage-build-simple-manual.md, manifest-parser/git-repo#6_build, LineageOS16_oneplus3t_gitRepoLs_clone_desc.pdf
LineageOS/android.git/cm-14.1 : 改为bfsu镜像
高通私有驱动 TheMuppets/proprietary_vendor_oneplus.git/cm-14.1/oneplus3 == TheMuppets/proprietary_vendor_oneplus/.git/8b8001
1. 仓库群下载工具准备
D=/OP3TLos14Build
cd $Dgit clone -b v2.50.1 https://mirrors.tuna.tsinghua.edu.cn/git/git-repo
#file /OP3TLos14Build/git-repo/.git/config
#file /OP3TLos14Build/git-repo/repoexport GitRepoD=/OP3TLos14Build/git-repo
export PATH_BASE=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
export PATH=$PATH_BASE:$GitRepoDwhich repo # == /OP3TLos14Build/git-repo/repo
2. 仓库群下载
LosVer=cm-14.1#repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/lineageOS/LineageOS/android.git -b cm-14.1 --git-lfsexport REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo'
#manifest_repo=https://mirrors.tuna.tsinghua.edu.cn/git/lineageOS/LineageOS/android.git
#manifest_repo=https://mirrors.bfsu.edu.cn/git/lineageOS/LineageOS/android.git
manifest_repo=https://gitlab.com/cm-14/android.git #已修改AOSP为国内镜像
repo init --manifest-url $manifest_repo --manifest-branch $LosVer --git-lfsrepo sync
循环显示所有仓库 : repo forall -c 'echo $PWD; echo $(git remote get-url $(git remote)) ; git reset --hard'
2b 我修改的代码
修改/OP3Los14Build/frameworks/base/.git/config
origin url为: https://gitlab.com/lineage14_1_oneplus3t/android_frameworks_base.git
3. 下载oneplus3相关仓库
packages/resources/devicesettings
git clone -b $LosVer https://github.com/LineageOS/android_packages_resources_devicesettings.git $D/packages/resources/devicesettings#若路径写错为 $D/packages/resources , mak bacon收到如下报错(在日志中距离很远):
# ERROR: resource directory 'device/oppo/common/configpanel/../../../../packages/resources/devicesettings/res' does not exist
# 其中 device/oppo/common/configpanel/../../../../packages/resources/devicesettings/res == packages/resources/devicesettings/res
# 提示 了 android_packages_resources_devicesettings.git 的正确路径是 packages/resources/devicesettings
oneplus3高通私有驱动(vendor)下载 方法1: 不用此法
下载 git仓库,但仓库有将近10个GB,因此不用此方法
注意: 目录TheMuppets-proprietary_vendor_oneplus
不要放在 /OP3TLos14Build
下, 否则 会被 mka showcommands bacon
认为和 软链接/OP3TLos14Build/vendor/oneplus/oneplus3
重复了。 这可能是cm-14.1的问题, 貌似 LinageOS-16无此问题.
#命令目标: 构造软链接: $D/vendor/oneplus/oneplus3 --> /app/TheMuppets-proprietary_vendor_oneplus/oneplus3#D=/OP3TLos14Build
#LosVer=cm-14.1
proprD=/app
proprietary_vendor_oneplus=$proprD/TheMuppets-proprietary_vendor_oneplus
git clone https://githubfast.com/TheMuppets/proprietary_vendor_oneplus.git -b $LosVer $proprietary_vendor_oneplus
#命令展开: git clone https://githubfast.com/TheMuppets/proprietary_vendor_oneplus.git -b cm-14.1 /app/TheMuppets-proprietary_vendor_oneplus
ln -s $proprietary_vendor_oneplus/oneplus3 $D/vendor/oneplus/oneplus3
#命令展开:ln -s /app/TheMuppets-proprietary_vendor_oneplus/oneplus3 /OP3TLos14Build/vendor/oneplus/oneplus3
oneplus3高通私有驱动(vendor)下载: 方法2: git仓库给定版本包
注意: 目录proprietary_vendor_oneplus-cm-14.1
不要放在 /OP3TLos14Build
下, 否则 会被 mka showcommands bacon
认为和 软链接/OP3TLos14Build/vendor/oneplus/oneplus3
重复了。 这可能是cm-14.1的问题, 貌似 LinageOS-16无此问题.
#命令目标: 构造软链接: $D/vendor/oneplus/oneplus3 --> /app/proprietary_vendor_oneplus-cm-14.1/oneplus3#D=/OP3TLos14Build
#LosVer=cm-14.1
proprD=/app
wget --output-document=$D/cm-14.1.zip https://github.com/TheMuppets/proprietary_vendor_oneplus/archive/refs/heads/$LosVer.zip
#命令展开: wget https://github.com/TheMuppets/proprietary_vendor_oneplus/archive/refs/heads/cm-14.1.zip
sha256sum $D/cm-14.1.zip #==f008b553dceac26b0feb26fdbda15c7c620ec4e3103c67b749a32900c83a55ec
unzip $D/$LosVer.zip -d $proprD
#命令展开: unzip /OP3TLos14Build/cm-14.1.zip -d /app/
#解压产物目录为 /app/proprietary_vendor_oneplus-cm-14.1
file /app/proprietary_vendor_oneplus-cm-14.1/oneplus3/Android.mk #解压产物列举
mkdir -p $D/vendor/oneplus
ln -s $proprD/proprietary_vendor_oneplus-cm-14.1/oneplus3 $D/vendor/oneplus/oneplus3
#命令展开: ln -s /app/proprietary_vendor_oneplus-cm-14.1/oneplus3 /OP3TLos14Build/vendor/oneplus/oneplus3
device/oneplus/oneplus3, device/oppo/common, kernel/oneplus/msm8996, packages/resources
#D=/OP3TLos14Build
#LosVer=cm-14.1git clone -b $LosVer https://github.com/LineageOS/android_device_oneplus_oneplus3.git $D/device/oneplus/oneplus3
git clone -b $LosVer https://github.com/LineageOS/android_device_oppo_common.git $D/device/oppo/common
git clone -b $LosVer https://github.com/LineageOS/android_kernel_oneplus_msm8996.git $D/kernel/oneplus/msm8996
4. 编译错误解决
0. 为方便排查错误 , 将编译进程数改为1 : 失败
sudo pstree -caplT
查看进程树
find /OP3TLos14Build/build/ -type f | xargs -I@ grep -Hn -i "\-j " @
/OP3TLos14Build/build/kati/flags.cc:104: ERROR("Invalid -j flag: %s", num_jobs_str);
/OP3TLos14Build/build/kati/flags.cc:110: ERROR("Invalid -j flag: %s", num_jobs_str);
/OP3TLos14Build/build/core/ninja.mk:128:# limited by the -j flag passed to GNU make.
/OP3TLos14Build/build/tools/makeparallel/Makefile:76: @EXPECTED="" $(MAKEPARALLEL_NINJA_TEST) -j -l
find /OP3TLos14Build/build/ -type f -name "*.mk" | xargs -I@ grep -Hn -i "job" @
/OP3TLos14Build/build/core/ninja.mk:129:NINJA_REMOTE_NUM_JOBS ?= 500
/OP3TLos14Build/build/core/ninja.mk:130:NINJA_ARGS += -j$(NINJA_REMOTE_NUM_JOBS)
将/OP3TLos14Build/build/core/ninja.mk
中的NINJA_REMOTE_NUM_JOBS ?= 500
改为NINJA_REMOTE_NUM_JOBS = 1
编译命令中的mka改为mk, -j8 改为 -j1
source build/envsetup.sh && export LC_ALL=C && export ALLOW_MISSING_DEPENDENCIES=true && lunch lineage_oneplus3-userdebug && export MAKE_OPTS="-j1" && export TARGET_ARCH=arm && mk bacon
则 确为单进程编译? 不确定,未验证
1.multiple definition of ‘yylloc’
解决编译错误, /usr/bin/ld: scripts/dtc/dtc-parser.tab.o:(.bss+0x50): multiple definition of 'yylloc'; scripts/dtc/dtc-lexer.lex.o:(.bss+0x0): first defined here
#D=/OP3TLos14Build
grep url $D/kernel/oneplus/msm8996/.git/config
# url = https://github.com/LineageOS/android_kernel_oneplus_msm8996.git
echo 'HOSTCFLAGS += -fcommon' >> $D/kernel/oneplus/msm8996/Makefile
2. Jack server
解决报错 Communication error with Jack server (56). Try 'jack-diagnose'
export ANDROID_JACK_VM_ARGS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx6G"
5A. 编译依赖工具安装
#所用linux发行版
cat /etc/issue #Ubuntu 22.04.4 LTS \n \l#查找deb包
sudo apt install -y apt-file
sudo apt-file update
lunch lineage_oneplus3-userdebug
需要的
sudo apt install -y build-essential
sudo apt install -y python2.7
sudo ln -s /usr/bin/python2.7 /usr/bin/python
mka bacon
需要的
1
apt-file search "/schedtool"
#schedtool: /usr/bin/schedtool
sudo apt install -y schedtool
2
apt-file search "/libncurses.so.5"
#libncurses5: /lib/x86_64-linux-gnu/libncurses.so.5
sudo apt install -y libncurses5
3
下载 https://static.azul.com/zulu/bin?C=S/zulu8.82.0.21-ca-jdk8.0.432-linux_x64.tar.gz
#查找jdk8的最新版本为 zulu8.82.0.21-ca-jdk8.0.432-linux_x64.tar.gz
pageUrl_azul_jdkLs="https://static.azul.com/zulu/bin?C=S"
alias alias_grep_jdk8_linux_x64_tar_gz_sort_head_n='grep jdk8 | grep linux_x64.tar.gz | sort --reverse | head -n'
w3m -T text/html $pageUrl_azul_jdkLs -dump | alias_grep_jdk8_linux_x64_tar_gz_sort_head_n 2
#[ ] zulu8.82.0.21-ca-jdk8.0.432-linux_x64.tar.gz 2024-10-10 102M
#[ ] zulu8.82.0.21-ca-fx-jdk8.0.432-linux_x64.tar.gz 2024-10-23 173M#下载zulu8.82.0.21-ca-jdk8.0.432-linux_x64.tar.gz
( cd /app/pack/ && wget https://static.azul.com/zulu/bin/zulu8.82.0.21-ca-jdk8.0.432-linux_x64.tar.gz )#解压
tar -xf zulu8.82.0.21-ca-jdk8.0.432-linux_x64.tar.gz -C /app/#测试
/app/zulu8.82.0.21-ca-jdk8.0.432-linux_x64/bin/javac -version
#javac 1.8.0_432
4
apt-file search "/ImageMagick"
sudo apt install -y imagemagick
#不是 libmagickcore-dev libmagick++-dev
5
prebuilts/misc/linux-x86/bison/bison
是32位ELF,
而ubuntu22 默认只支持64位ELF, 因此 要安装32位兼容库
prebuilts/misc/linux-x86/bison/bison --help #报错 说`No such file or directory` , 实际是因为没有32位ELF加载器ldsudo dpkg --add-architecture i386
sudo apt updatesudo apt install -y libc6:i386 libstdc++6:i386
prebuilts/misc/linux-x86/bison/bison --help #正常运行
6.
报错命令:
prebuilts/misc/linux-x86/bison/bison -d --defines=/OP3TLos14Build/out/host/linux-x86/obj/STATIC_LIBRARIES/libaidl-common_intermediates/aidl_language_y.h -o /OP3TLos14Build/out/host/linux-x86/obj/STATIC_LIBRARIES/libaidl-common_intermediates/aidl_language_y.cpp system/tools/aidl/aidl_language_y.yy
#prebuilts/misc/linux-x86/bison/bison: m4 subprocess failed: No such file or directory
解决
sudo apt install -y m4
7. javadoc报错不影响编译 : error: package android.support.v14.preference does not exist
source build/envsetup.sh && export LC_ALL=C && export ALLOW_MISSING_DEPENDENCIES=true && lunch lineage_oneplus3-userdebug && export MAKE_OPTS="-j8" && export TARGET_ARCH=arm && mka showcommands bacon
报错:
cat -n OP3-cm14_1-screen-2025-01-18-17-58-22.log | grep -i "error:"
注意 此报错是javadoc命令报错, 不影响继续编译, 因此可以忽略此错误
8868 vendor/cmsdk/sdk/src/java/cyanogenmod/preference/SelfRemovingSwitchPreference.java:19: error: package android.support.v14.preference does not exist8871 vendor/cmsdk/sdk/src/java/cyanogenmod/preference/SelfRemovingSwitchPreference.java:20: error: package android.support.v7.preference does not exist8874 vendor/cmsdk/sdk/src/java/cyanogenmod/preference/SelfRemovingSwitchPreference.java:27: error: cannot find symbol8878 vendor/cmsdk/sdk/src/java/cyanogenmod/preference/ConstraintsHelper.java:27: error: package android.support.v7.preference does not exist8881 vendor/cmsdk/sdk/src/java/cyanogenmod/preference/ConstraintsHelper.java:28: error: package android.support.v7.preference does not exist8884 vendor/cmsdk/sdk/src/java/cyanogenmod/preference/ConstraintsHelper.java:29: error: package android.support.v7.preference does not exist8887 vendor/cmsdk/sdk/src/java/cyanogenmod/preference/ConstraintsHelper.java:30: error: package android.support.v7.preference does not exist8890 vendor/cmsdk/sdk/src/java/cyanogenmod/preference/SelfRemovingSwitchPreference.java:47: error: cannot find symbol8895 vendor/cmsdk/sdk/src/java/cyanogenmod/preference/ConstraintsHelper.java:61: error: cannot find symbol8900 vendor/cmsdk/sdk/src/java/cyanogenmod/preference/ConstraintsHelper.java:71: error: cannot find symbol8905 vendor/cmsdk/sdk/src/java/cyanogenmod/preference/ConstraintsHelper.java:100: error: cannot find symbol8910 vendor/cmsdk/sdk/src/java/cyanogenmod/preference/ConstraintsHelper.java:100: error: cannot find symbol8915 vendor/cmsdk/sdk/src/java/cyanogenmod/preference/ConstraintsHelper.java:104: error: cannot find symbol8920 vendor/cmsdk/sdk/src/java/cyanogenmod/preference/ConstraintsHelper.java:104: error: cannot find symbol8925 vendor/cmsdk/sdk/src/java/cyanogenmod/preference/ConstraintsHelper.java:104: error: cannot find symbol8930 vendor/cmsdk/sdk/src/java/cyanogenmod/preference/ConstraintsHelper.java:299: error: cannot find symbol8935 vendor/cmsdk/sdk/src/java/cyanogenmod/preference/SelfRemovingListPreference.java:19: error: package android.support.v7.preference does not exist8938 vendor/cmsdk/sdk/src/java/cyanogenmod/preference/SelfRemovingListPreference.java:20: error: package android.support.v7.preference does not exist8941 vendor/cmsdk/sdk/src/java/cyanogenmod/preference/SelfRemovingListPreference.java:27: error: cannot find symbol8945 vendor/cmsdk/sdk/src/java/cyanogenmod/preference/SelfRemovingListPreference.java:47: error: cannot find symbol8950 vendor/cmsdk/sdk/src/java/cyanogenmod/preference/SelfRemovingDropDownPreference.java:19: error: package android.support.v7.preference does not exist8953 vendor/cmsdk/sdk/src/java/cyanogenmod/preference/SelfRemovingDropDownPreference.java:20: error: package android.support.v7.preference does not exist8956 vendor/cmsdk/sdk/src/java/cyanogenmod/preference/SelfRemovingDropDownPreference.java:27: error: cannot find symbol8960 vendor/cmsdk/sdk/src/java/cyanogenmod/preference/SelfRemovingDropDownPreference.java:47: error: cannot find symbol8965 vendor/cmsdk/sdk/src/java/cyanogenmod/preference/ConstraintsHelper.java:351: error: cannot find symbol8970 vendor/cmsdk/sdk/src/java/cyanogenmod/preference/ConstraintsHelper.java:351: error: cannot find symbol8975 vendor/cmsdk/sdk/src/java/cyanogenmod/preference/ConstraintsHelper.java:351: error: cannot find symbol8980 vendor/cmsdk/sdk/src/java/cyanogenmod/preference/ConstraintsHelper.java:355: error: cannot find symbol8985 vendor/cmsdk/sdk/src/java/cyanogenmod/preference/ConstraintsHelper.java:355: error: cannot find symbol8990 vendor/cmsdk/sdk/src/java/cyanogenmod/preference/ConstraintsHelper.java:355: error: cannot find symbol8995 vendor/cmsdk/sdk/src/java/cyanogenmod/preference/ConstraintsHelper.java:369: error: cannot find symbol9000 vendor/cmsdk/sdk/src/java/cyanogenmod/preference/ConstraintsHelper.java:369: error: cannot find symbol9005 vendor/cmsdk/sdk/src/java/cyanogenmod/preference/ConstraintsHelper.java:377: error: cannot find symbol9010 vendor/cmsdk/sdk/src/java/cyanogenmod/preference/RemotePreference.java:26: error: package android.support.v7.preference does not exist9013 vendor/cmsdk/sdk/src/java/cyanogenmod/preference/SelfRemovingPreference.java:19: error: package android.support.v7.preference does not exist9016 vendor/cmsdk/sdk/src/java/cyanogenmod/preference/SelfRemovingPreference.java:20: error: package android.support.v7.preference does not exist9019 vendor/cmsdk/sdk/src/java/cyanogenmod/preference/SelfRemovingPreference.java:21: error: package android.support.v7.preference does not exist9022 vendor/cmsdk/sdk/src/java/cyanogenmod/preference/SelfRemovingPreference.java:28: error: cannot find symbol9026 vendor/cmsdk/sdk/src/java/cyanogenmod/preference/SelfRemovingPreference.java:52: error: cannot find symbol
简要确认此报错是javadoc命令产生的
cat -n OP3-cm14_1-screen-2025-01-18-17-58-22.log | grep -B 1 -i "vendor/cmsdk/sdk/src/java/cyanogenmod/preference/SelfRemovingSwitchPreference.java:19: error: package android.support.v14.preference does not exist" | grep javadoc
匹配到javadoc命令
8. ninja: build stopped: subcommand failed.
需要具体排查
wc -l OP3-cm14_1-screen-2025-01-18-17-58-22.log
== 85313
cat -n OP3-cm14_1-screen-2025-01-18-17-58-22.log | tail -n 8
有报错
85306 ninja: build stopped: subcommand failed.85307 make: *** [build/core/ninja.mk:152: ninja_wrapper] Error 185308 make: Leaving directory '/OP3TLos14Build'85309 85310 #### make failed to build some targets (02:06:05 (hh:mm:ss)) ####
如果能将ninja的并发数改为1, 报错行将会大大靠近结果, 排查难道会降低
8.1 查找 error:
(排除)
grep -Hn -i "error:" OP3-cm14_1-screen-2025-01-18-17-58-22.log
: 获得的是 7 中的javadoc报错(不影响继续编译)
8.2 查找command not found
(疑似)
grep -Hn "command not found" OP3-cm14_1-screen-2025-01-18-17-58-22.log
85296: /bin/bash: line 1: xmllint: command not found
距离 85306 ninja: build stopped: subcommand failed.
只有10行, 因此 可能是此报错
解决
apt-file search --regexp "/xmllint$"
#libxml2-utils: /usr/bin/xmllint
sudo apt install -y libxml2-utils
5B. github加速
加速githubusercontent(可选)
githubusercontent
后加s
#D=/OP3TLos14Build
sed -i 's/raw.githubusercontent.com/raw.githubusercontents.com/g' $D/vendor/cm/vendorsetup.sh
提高 source build/envsetup.sh
速度
已修改在: lineage14_1_oneplus3t/android_vendor_cm.git/3a218
5. 编译
screen -L -Logfile ~/OP3-cm14_1-screen-$(date +%Y-%m-%d-%H-%M-%S).log -S OP3#编译步骤正文 开始
D=/OP3TLos14Build
cd $Djdk8_d=/app/zulu8.82.0.21-ca-jdk8.0.432-linux_x64
export PATH_BASE=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
export PATH=$PATH_BASE:$jdk8_d/binexport ANDROID_JACK_VM_ARGS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx6G"#单行编译命令 开始
source build/envsetup.sh#export V=1
export LC_ALL=C
export ALLOW_MISSING_DEPENDENCIES=true
#export DEBUG_MODULE_android_runtime=true
#export TARGET_CUSTOM_DEBUG_CFLAGS="-O0 -g"
#export MAKE_OPTS="-j8"
#export TARGET_ARCH=arm
lunch lineage_oneplus3-userdebug && mka showcommands bacon # lineage_oneplus3-eng
#单行编译命令 结束#编译步骤正文 结束#离开screen但不退出快捷键: ctrl+ad#进入screen : screen -r OP3#编译完成后 关闭 jack服务
$D/prebuilts/sdk/tools/jack-admin stop-server
编译步骤 中 不同用途 的 单行编译命令
完整编译
source build/envsetup.sh && export LC_ALL=C && export ALLOW_MISSING_DEPENDENCIES=true && lunch lineage_oneplus3-userdebug && export MAKE_OPTS="-j8" && export TARGET_ARCH=arm && mka showcommands bacon
6 编译产物(ota rom卡刷包)
ls -lh /OP3TLos14Build/out/target/product/oneplus3/lineage-14.1-20250117-UNOFFICIAL-oneplus3.zip
# -rw-rw-r-- 506M source /app/bash-simplify/android_aid/env/android9.0-platform-tools-env.sh && android9_0_platformTools_envfastboot boot /oneplus3t/twrp-3.2.1-0-oneplus3.img
#twrp界面: Wipe所有, Advance --> adb sideload (勾选清理所有)adb sideload /OP3TLos14Build/out/target/product/oneplus3/lineage-14.1-20250117-UNOFFICIAL-oneplus3.zipadb reboot
#重启手机, linageOS图标 大约转了30圈 才进入 android首次安装界面
7. lineageOS-14/ adb root
lineageOS-14(android7)的开发者模式/usb调试(adb)启用root功能
adb root shell
adb shell
进入root shell, 比如可以挂载system分区为可读可写
lineageOS-17的adb 进不到root shell, 只能重启到twrp 才能进到root shell
mount -o remount,rw /system
echo zzz > /system/test_file_1
rm -v /system/test_file_1mount -o remount,ro /system
备注
一般备注
grep url $D/.repo/manifests/.git/config
# url = https://gitlab.com/cm-14/android.git#查看screen日志
tail -f ~/OP3-screen-*.log#关机命令
sleep 60 ; cd /tmp; echo z |sudo -S umount /OP3TLos14Build ; echo z |sudo -S umount /mnt/OP3TLos14Build ; echo z |sudo -S poweroff
确认版本号 为 cm-14.1
cd /tmp/
git clone https://mirrors.bfsu.edu.cn/git/lineageOS/LineageOS/android.git
cd /tmp/android/git --no-pager branch --all | grep cm-14.1 # == remotes/origin/cm-14.1
git --no-pager tag --list | grep cm-14.1 #无