Setting Up LineageOS 21/AOSP 14 Environment for Xiaomi and Nubia Phones

Background

Currently, various manufacturers’ phones have started to ship with AOSP 14, which is Android 14. By 2024, all phones will be running on Android 14.

I’ve been closely monitoring whether LineageOS has timely upgraded to the latest Android 14. Today, I checked the official website and indeed found that it has been upgraded. I also set up the environment for compilation at the first opportunity. However, during the process, I discovered some differences compared to the previous version. Therefore, I need to document these differences for reference to help students avoid unsuccessful setups. With my guidance, everyone can save a lot of time in the setup process.

This section only discusses the differences; please refer to the following link for details:

https://blog.csdn.net/learnframework/article/details/128438325

Related Differences Sharing:

1 breakfast nx563j

Directly reported an error unable to fetch from GitHub: Failed to fetch data from GitHub. If you encounter this error, you can check the relevant source code:

githubreq = urllib.request.Request("https://raw.githubusercontent.com/LineageOS/mirror/main/default.xml")
Python

This path is inaccessible over the network, which leads to the inability to fetch. Ultimately, this is due to our network issues. So how can we effectively resolve this?

I remember that during AOSP 13, there were no issues with LineageOS. I checked the old version of this file and found that its code is as follows:

githubreq = urllib.request.Request("https://api.github.com/search/repositories?q=%s+user:LineageOS+in:name+fork:true" % device)
Python

The accessed addresses are quite different. Therefore, I attempted to directly overwrite the old version of vendor/lineage/build/tools/roomservice.py:

cp ~/nx563j_xiaomi/vendor/lineage/build/tools/roomservice.py vendor/lineage/build/tools/roomservice.py
Python

If not available, just copy it from here:

vendor/lineage/build/tools/roomservice.py
Python

#!/usr/bin/env python
# Copyright (C) 2012-2013, The CyanogenMod Project
#           (C) 2017-2018,2020-2021, The LineageOS Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# you may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import print_function

import base64
import json
import netrc
import os
import re
import sys
try:
  # For python3
  import urllib.error
  import urllib.parse
  import urllib.request
except ImportError:
  # For python2
  import imp
  import urllib2
  import urlparse
  urllib = imp.new_module('urllib')
  urllib.error = urllib2
  urllib.parse = urlparse
  urllib.request = urllib2

from xml.etree import ElementTree

product = sys.argv[1]

if len(sys.argv) > 2:
    depsonly = sys.argv[2]
else:
    depsonly = None

try:
    device = product[product.index("_") + 1:]
except:
    device = product

if not depsonly:
    print("Device %s not found. Attempting to retrieve device repository from LineageOS Github (http://github.com/LineageOS)." % device)

repositories = []

try:
    authtuple = netrc.netrc().authenticators("api.github.com")

    if authtuple:
        auth_string = ('%s:%s' % (authtuple[0], authtuple[2])).encode()
        githubauth = base64.encodestring(auth_string).decode().replace('\n', '')
    else:
        githubauth = None
except:
    githubauth = None

# ... [rest of the code omitted for brevity] ...
Python

2 ./extract-files.sh has a few errors

The solution is to flash the phone with the latest version of LineageOS. The version download link:

https://download.lineageos.org/devices/nx563j/builds

After flashing to the latest version, executing ./extract-files.sh will have no errors.

3 Compilation error with webview.apk

Solution:

1. You can find webview.apk from the flashed phone and copy it to the path of the erroring apk.

2. Copy webview.apk from the previous successful compilation code as follows:

cp ~/nx563j_xiaomi/external/chromium-webview/prebuilt/arm64/webview.apk external/chromium-webview/prebuilt/arm64/webview.apk
Python

Finally, it succeeded as follows:

Setting Up LineageOS 21/AOSP 14 Environment for Xiaomi and Nubia Phones
Insert image description here
Setting Up LineageOS 21/AOSP 14 Environment for Xiaomi and Nubia Phones
Insert image description here

More detailed code and materials in this article require course purchase to obtain.

hal+perfetto+surfaceflinger
https://mp.weixin.qq.com/s/LbVLnu1udqExHVKxd74ILg

Setting Up LineageOS 21/AOSP 14 Environment for Xiaomi and Nubia Phones
Insert image description here

Private message the author +v(androidframework007)

Setting Up LineageOS 21/AOSP 14 Environment for Xiaomi and Nubia Phones

Other courses seven-piece set topic:

Setting Up LineageOS 21/AOSP 14 Environment for Xiaomi and Nubia Phones
Insert image description here

Click here https://mp.weixin.qq.com/s/Qv8zjgQ0CkalKmvi8tMGaw

Video preview: https://www.bilibili.com/video/BV1wc41117L4/

Leave a Comment