编译魔趣源码

说明

本文编译的是魔趣系统源码AOSP 10 r41版本,其他源码也可作为参照,本文中全程用的是普通用户编译,没有使用root,部分需要root权限会在文中说明

Q: 什么是魔趣系统?
A: 魔趣 ROM 基于 Android 开源项目 (AOSP) 二次开发,相关地址:https://www.mokeedev.com/

Q: 为什么选魔趣?
A: 没有谷歌手机,而魔趣支持的机型目前是市场上比较多的,而且是开源的。

建议在科学上网的环境下进行操作

本机环境

  • Windows 10
  • Kali Linux 虚拟机
  • 虚拟机已具备科学上网能力

给Kali虚拟机分配了350G硬盘空间,和20G运行内存,一般在15G即可

编译环境

在准备编译环境前,使用su命令切换到root用户下 ,安装完成后,在切换到当前用户

在Kali Linux 上装以下环境:

  1. python3.x (什么版本都行)
  2. jdk (本机是jdk11)

依赖库如下:

apt-get install libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-dev g++-multilib
apt-get install -y git flex bison gperf build-essential libncurses5-dev:i386
apt-get install tofrodos python-markdown libxml2-utils xsltproc zlib1g-dev:i386
apt-get install dpkg-dev libsdl1.2-dev libesd0-dev
apt-get install git-core gnupg flex bison gperf build-essential
apt-get install zip curl zlib1g-dev gcc-multilib g++-multilib
apt-get install libc6-dev-i386
apt-get install lib32ncurses5-dev x11proto-core-dev libx11-dev
apt-get install libgl1-mesa-dev libxml2-utils xsltproc unzip m4
apt-get install lib32z-dev ccache
apt-get install libssl-dev
apt-get install m4
apt install bc
apt install liblz4-tool

拷贝源码

这里使用魔趣官方提供的repo文件, 下载地址:https://www.aliyundrive.com/s/1ongW5RP7Y3

使用su命令切换到root用户下 ,完成以下操作,在切换到当前用户

mv repo /usr/bin/repo
chmod a+x repo

完成上面操作后,切换到普通用户,然后选一个文件夹,输入以下命令,下载源码

如果想替换国内源的,可以在下面找到切换下载源章节后再回到这里

git config --global user.email "[email protected]"
git config --global user.name "Your Name"
repo init -u https://github.com/MoKee/android -b mkq-mr1 --depth 1
repo sync

如果是在repo init命令上遇见某种原因失败,需要重试的,可以输入以下命令:

rm -rf .repo
repo init -u https://github.com/MoKee/android -b mkq-mr1 --depth 1
repo sync

如果在repo sync失败的,建议把当前文件夹删除,在重新建文件夹,进入到刚建立的文件夹中,输入以下命令重试:

repo init -u https://github.com/MoKee/android -b mkq-mr1 --depth 1
repo sync

这里需要等待很久,建议安装jnettop来监控网络情况

切换下载源

但执行了repo init命令后,在当前路径下,进入.repo/manifests文件夹中,对default.xml进行换源,本机中换的是清华源 https://mirrors.tuna.tsinghua.edu.cn/git/AOSP

编译

下载完源码后,基本上完成了一半,在普通用户下输入以下命令:

source ./build/envsetup.sh

下一步,需要说明
lunch mokee_设备号-userdebug

这里的设备号是需要在魔趣官网查看的,我的是U3 Pro,所以我的设备号为:osborn,那么我应该输入以下命令:

lunch mokee_osborn-userdebug
mka bacon

最后编译时间和电脑配置有巨大影响,本机是4核CPU,用时3小时左右

谢谢楼主,问下源码是哪里弄来的,可以分享一下吗,或者邮箱联系也可

这命令就是下载源码的意思

好的谢谢,我先在虚拟机上安装repo

楼主你好,我在编译的时候发生了以下错误,找不到手机型号
我的repo是用的楼主你的,这会是哪里出错了呢?
求教!
[email protected]:~/mokee# source ./build/envsetup.sh
[email protected]:~/mokee# lunch mokee_osborn-userdebug
[W][2022-06-28T23:15:50-0700][7110] void cmdline::logParams(nsjconf_t *)():250 Process will be UID/EUID=0 in the global user namespace, and will have user root-level access to files
[W][2022-06-28T23:15:50-0700][7110] void cmdline::logParams(nsjconf_t *)():260 Process will be GID/EGID=0 in the global user namespace, and will have group root-level access to files
build/make/core/product_config.mk:223: error: Can not locate config makefile for product “mokee_osborn”.
23:15:51 dumpvars failed with: exit status 1
Device osborn not found. Attempting to retrieve device repository from MoKee Open Source Github (MoKee · GitHub).

找不到型号,和repo文件没有关系,检查一下下源码的时候git地址有没有搞错

repo init -u https://github.com/MoKee/android -b mkq-mr1 --depth 1
1 Like

没错呀,每一步都是复制楼主的
我重新repo init 一下再同步一次

没错呀,每一步都是复制楼主的
我重新repo init 一下再同步一次

[email protected]:~/mkk# /usr/bin/repo init -u GitHub - MoKee/android -b mkq-mr1 --depth 1
Downloading Repo source from GitHub - MoKee/git-repo
remote: Enumerating objects: 7592, done.
remote: Counting objects: 100% (1804/1804), done.
remote: Compressing objects: 100% (841/841), done.
remote: Total 7592 (delta 1336), reused 1422 (delta 954), pack-reused 5788
Receiving objects: 100% (7592/7592), 3.52 MiB | 1.71 MiB/s, done.
Resolving deltas: 100% (4877/4877), done.

Your identity is: sjwa [email protected]
If you want to change this, please re-run ‘repo init’ with --config-name

repo has been initialized in /root/mkk/
If this is not the directory in which you want to initialize repo, please run:
rm -r /root/mkk//.repo
and try again.

楼主,再叨扰你一下,我记得之前同步源码的时候设置了代理服务器
[email protected]:~/mk# git config --global -l
[email protected]
user.name=sjwa
color.ui=auto
http.https://github.com.proxy=http://127.0.0.1:7890
https.https://github.com.proxy=https://127.0.0.1:7890
http.proxy=http://127.0.0.1:7890
https.proxy=http://127.0.0.1:7890
请问我这个错和上面设置代理服务器没关系吧,因为我用的是clash科学上网,需要设置代理127.0.0.1:7890

上面那个不是错误,执行成功了,然后运行repo sync 就行,另外科学上网我使用是iptable设置的全局。git相关设置我也不太明白

是成功了
我记得上次是repo sync后提示有东西没下完整,让我输入 -fix什么的,一路按提示走最后显示successful,这次我看看是什么情况,
我很需要这个源码,因为xiaomi的原生源码很难找,我还要进行修改

如果失败建议删除当前目录,重头开始

是的,每次同步失败后我都删除文件夹,重新建的,再repo init 再同步

楼主,下载成功了中间也没有任何错误,请问lunch的时候直接卡住是什么问题?
还有在执行./build/envsetup.sh的时候不应该输出一大串信息么,我这里直接不显示
Checking out: 100% (770/770), done in 1h4m57.577s
repo sync has finished successfully.
[email protected]:~/mokee# source ./build/envsetup.sh
[email protected]:~/mokee# lunch

又出现了新问题,我在网上找到了安装python-lunch的方法
后来运行lunch的时候提示No such file: /root/.lunchrc
所以envsetup.sh还是执行不了,因为上面执行的时候没有输出信息

lunch后确实会卡住,应该来说他会做某些事情,我大概等待了三十分钟左右,有可能他在执行下载或者其他事情,最好等待,不要强制结束

1 Like

楼主,这还是没有对应型号的选择选项,这是什么引起的呢?
[email protected]:~/mokee# lunch
[W][2022-06-29T19:11:25-0700][2701] void cmdline::logParams(nsjconf_t *)():250 Process will be UID/EUID=0 in the global user namespace, and will have user root-level access to files
[W][2022-06-29T19:11:25-0700][2701] void cmdline::logParams(nsjconf_t *)():260 Process will be GID/EGID=0 in the global user namespace, and will have group root-level access to files

You’re building on Linux

Lunch menu… pick a combo:
1. aosp_arm-eng
2. aosp_arm64-eng
3. aosp_car_arm-userdebug
4. aosp_car_arm64-userdebug
5. aosp_car_x86-userdebug
6. aosp_car_x86_64-userdebug
7. aosp_x86-eng
8. aosp_x86_64-eng
9. car_x86_64-userdebug
10. m_e_arm-userdebug
11. mini_emulator_arm64-userdebug
12. mini_emulator_x86-userdebug
13. mini_emulator_x86_64-userdebug
14. mokee_arm-userdebug
15. mokee_arm64-userdebug
16. mokee_x86-userdebug
17. mokee_x86_64-userdebug
18. qemu_trusty_arm64-userdebug
19. uml-userdebug

Which would you like? [aosp_arm-eng]

出现了这个结果…

等等楼主,我这里直接执行型号,发现他在下载些什么东西
[email protected]:~/mokee# lunch mokee_sirius-userdebug
[W][2022-06-29T19:16:50-0700][2785] void cmdline::logParams(nsjconf_t *)():250 Process will be UID/EUID=0 in the global user namespace, and will have user root-level access to files
[W][2022-06-29T19:16:50-0700][2785] void cmdline::logParams(nsjconf_t *)():260 Process will be GID/EGID=0 in the global user namespace, and will have group root-level access to files
build/make/core/product_config.mk:223: error: Can not locate config makefile for product “mokee_sirius”.
19:16:51 dumpvars failed with: exit status 1
Device sirius not found. Attempting to retrieve device repository from MoKee Open Source Github (MoKee · GitHub).
Found repository: android_device_xiaomi_sirius
Default revision: mkq-mr1
Checking branch info
Checking if device/xiaomi/sirius is fetched from android_device_xiaomi_sirius
Adding dependency: MoKee/android_device_xiaomi_sirius → device/xiaomi/sirius
Using default branch for android_device_xiaomi_sirius
Syncing repository to retrieve project.
remote: Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
Fetching: 100% (1/1) MoKee/android_device_xiaomi_sirius
Fetching: 100% (1/1), done in 10.188s
Garbage collecting: 100% (1/1), done in 0.007s
repo sync has finished successfully.
Repository synced!
Looking for dependencies in device/xiaomi/sirius
Adding dependencies to manifest
Checking if vendor/xiaomi/sirius is fetched from android_vendor_xiaomi_sirius
Adding dependency: MoKee/android_vendor_xiaomi_sirius → vendor/xiaomi/sirius
Using default branch for android_vendor_xiaomi_sirius
Checking if kernel/xiaomi/sdm710 is fetched from android_kernel_xiaomi_sdm710
Adding dependency: MoKee/android_kernel_xiaomi_sdm710 → kernel/xiaomi/sdm710
Using default branch for android_kernel_xiaomi_sdm710
Syncing dependencies
remote: Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
Fetching: 0% (0/2) warming up