Ubuntu virtual machine environment to build Android system source code compilation environment and problem solving methods

1. Get the Android source code and network configuration to access google (method one)

2. Get the Android source code network configuration to access google (method two)

3. Change the apt source to Aliyun source under Ubuntu 18.04

Fourth, the solution to the certificate problem when the proxy causes the network to be inaccessible

5. The operation method for ordinary users in the Ubuntu environment to automatically download the source code of each version of the Android system of the LineageOS supported models

6. MoKee (Magic Fun) or LineageOS

Seven, MoKee magic

Eight, commonly used Android system source code compilation basis

Nine, the solution to the problem of port occupation

10. Increase Swap partition on Ubuntu 16.04 

11. Insufficient disk space, you can use the following methods to expand disk space

12. If you can't access google, add the equipment selection model of the compilation system to the Mokee mirror (lunch)

13. In the case of unable to access google, Lineage OS mirroring adds the equipment selection model of the compilation system (lunch)

 

1. Get the Android source code and network configuration to access google (method one) 

image

 

image

 

Set up http, https and ftp proxy ( where IP is the host IP address )

export http_proxy=socks5://172.20.10.2:1080

export https_proxy=socks5://172.20.10.2:1080

export FTP_PROXY=socks5://172.20.10.2:1080

export ALL_PROXY=socks5://172.20.10.2:1080

 

Set up http proxy ( where IP is the host IP address )

git config --global http.proxy http://172.20.10.2:1080

git config --global https.proxy https://172.20.10.2:1080

git config --global user.email "****@email.address"

git config --global user.name "****"

 

Cancel http proxy

git config --system (或 --global 或 --local) --unset http.proxy

git config --system (or --global or --local) --unset https.proxy

 

2. Get the Android source code network configuration to access google ( method two ) 

image

 

image

 

3. Change the apt source to Aliyun source under Ubuntu 18.04

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

sudo apt-get install vim

 

Comment out the original content and add the following

sudo vim /etc/apt/sources.list

or

sudo gedit /etc/apt/sources.list

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

 

Update software list

sudo apt-get update

 

Update package

sudo apt-get upgrade

 

Fourth, the solution to the certificate problem when the proxy causes the network to be inaccessible

Cancel proxy

git config --global --unset http.proxy

git config --global --unset https.proxy

 

Delete local configuration file

apt-get purge openssl

rm -rf /etc/ssl

 

re-install

sudo apt-get install libssl-dev openssl

apt-get install ca-certificates

 

5. The operation method for ordinary users in the Ubuntu environment to automatically download the source code of each version of the Android system of the LineageOS supported models

(1). Obtain root permissions

sudo su

Follow the steps of https://wiki.lineageos.org/devices/ to obtain the Android system source code (the method of obtaining the source code for each model is similar), as shown in the figure:

https://wiki.lineageos.org/devices/hammerhead/build (similar to other models)

image

 

image

 

image

 

image

 

image

 

image

 

image

 

6. MoKee (Magic Fun) or LineageOS

(1). The method of downloading the device, kernel, vendor system source code supported by each model through git (similar to each model) is as follows:

https://github.com/LineageOS/android_device_xiaomi_cancro

https://github.com/LineageOS/android_kernel_xiaomi_cancro

https://github.com/MoKee/android_vendor_xiaomi_cancro

https://github.com/MoKee/android_device_xiaomi_cancro

https://github.com/MoKee/android_kernel_xiaomi_cancro

 

https://github.com/LineageOS/android_device_lge_hammerhead

https://github.com/LineageOS/android_kernel_lge_hammerhead

https://github.com/MoKee/android_vendor_lge_hammerhead

https://github.com/MoKee/android_kernel_lge_hammerhead

 

https://github.com/LineageOS/android_device_huawei_angler

https://github.com/MoKee/android_vendor_huawei_angler

https://github.com/LineageOS/android_kernel_huawei_angler

 

(2). Configure Android system source code compilation environment (ordinary users)

vim ~/.bashrc

image

 

source ~/.bashrc

 

./prebuilts/sdk/tools/jack-admin kill-server

./prebuilts/sdk/tools/jack-admin start-server

 

(3). Configure Android system source code compilation environment (root user)

vim ~/.bashrc

 

export USE_CCACHE=1

export CCACHE_EXEC=/usr/bin/ccache

ccache -M 50G

export CCACHE_COMPRESS=1

export ANDROID_JACK_VM_ARGS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4096"

export JACK_SERVER_VM_ARGUMENTS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4096m"

export LC_ALL=C

 

image

 

source ~/.bashrc

 

./prebuilts/sdk/tools/jack-admin kill-server

./prebuilts/sdk/tools/jack-admin start-server

 

image

 

Seven, MoKee magic

Install Repo

Create a bin folder in the root directory of the current user and add it to the system environment variables

mkdir ~/bin

PATH=~/bin:$PATH

 

Download Repo and give execution permission

curl https://download.mokeedev.com/git-repo-downloads/repo > ~/bin/repo

curl https://raw.githubusercontent.com/MoKee/git-repo/stable/repo > ~/bin/repo

chmod a+x ~/bin/repo

 

image

 

8.1 Magic Fun source code, branch modified to mko-mr1

repo init -u https://github.com/MoKee/android -b mko -mr1

repo sync

repo sync -f -j8

repo sync -c -f -j8 --force-sync --no-clone-bundle

 

Command to compile Android 8.1

make bacon

make bacon -j4

make bacon -j8

make bacon -j16

 

. 9 . 0 magic interesting source, is modified to branch mkp

git config --global http.proxy http://192.168.101.102:1080

git config --global https.proxy https://192.168.101.102:1080

 

git config --global user.email "[email protected]"

git config --global user.name "gouyp"

repo init -u https://github.com/MoKee/android -b mkp

repo init -u https://github.com/MoKee/android -b mkp-dev

repo init -u https://github.com/MoKee/android.git -b mkp

repo sync

 

. 9 . 0 magic interesting source compiled

. build/envsetup.sh && lunch (enter device number) && mka bacon

 

repo init -u https://github.com/MoKee/android -b mkp --depth 1

repo sync

. build/envsetup.sh

lunch

 

Compiler options: 28 ( OnePlus 6 models)

mka bacon

mka bacon  -j8

 

One-key flashing method for Android system

image

 

fastboot --disable-verity --disable-verification flash vbmeta stock_vbmeta.img

fastboot flash vbmeta vbmeta.img

fastboot flash boot boot.img

fastboot flash system system.img

fastboot flash userdata userdata.img

fastboot -w reboot

 

image

 

image

 

image

 

image

 

image

 

Eight, commonly used Android system source code compilation basis

Delete all configuration compiled and output result files

make clobber

 

After adding the system API or modifying the API of @hide, you need to execute the following command, and then make

make update-api

 

After modifying the public API, you need to execute the following command, and then make

make update-api

 

Sub-module compilation

Compile boot.img

make bootimage

 

Compile userdata.img

make userdataimage

 

Compile system.img

make systemimage

 

Repackage system.img

make snod

 

Pre-install the App into the system (Apps that need to be pre-installed are provided in source code form, and need to be compiled first)

Execute the following command in the source root directory

source build/envsetup.sh

mmm packages/apps/TestApp

 

After the compilation is completed, the corresponding apk file will be generated under the path out/target/product/xxx/system/app/ (xxx is the device code). If there is already an apk file, it will be placed directly in this path; if it is a system application, It should be placed in the out/target/product/xxx/system/priv-app/ path, and then you need to repackage it into an image file, return to the source root directory, and execute the following command to repackage system.img

make snod

 

Nine, the solution to the problem of port occupation

netstat -tln | grep jack-port number, only view the usage of port jack-port

lsof -i:jack-port number to check which program the port belongs to and which process the port is occupied by

kill -9 jack-port number process pid

 

sudo vim ~/.jack-settings

image

 

sudo vim ~/.jack-server/config.propertie 

image

sudo chmod 600 ~/.jack-settings

sudo chmod 600 ~/.jack-server/config.properties

 

sudo vim ~/.bashrc

sudo source ~/.bashrc 

image

 

image

 

export USE_CCACHE=1

export CCACHE_EXEC=/usr/bin/ccache

ccache -M 50G

export CCACHE_COMPRESS=1

export ANDROID_JACK_VM_ARGS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4096"

export JACK_SERVER_VM_ARGUMENTS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4096m"

export LC_ALL=C

 

./out/host/linux-x86/bin/jack-admin stop-server

./out/host/linux-x86/bin/jack-admin start-server

 

./prebuilts/sdk/tools/jack-admin kill-server

./prebuilts/sdk/tools/jack-admin start-server

 

10. Increase Swap partition on Ubuntu 16.04 

image

 

Check the disk space size

df -h

 

Check the file size on the disk

du -sh

 

View memory usage

free -m

 

gnome-system-monitor

 

11. Insufficient disk space, you can use the following methods to expand disk space

image

 

Install gparted partition management software

sudo apt-get install gparted

image

 

image

 

https://blog.csdn.net/u011345885/article/details/73060897

 

Twelve, google can not access the situation under the magic mirror add interest Mokee compilation system equipment selection number (lunch) 

image

 

XIII can not access google's case L under ineage  OS image to add compilation system equipment selection number (lunch)

image

 

The implementation of vendorsetup.sh files in the corresponding subdirectories of vendor and device, they are mainly to add the corresponding device model and its compilation type support to the Lunch menu

 

Add add_lunch_combo aosp_angler-userdebug in device/huawei/angler/vendorsetup.sh to the end of vendor/cm/vendorsetup.sh, you can enter the lunch command to get the device selection model when compiling the source code

image

 

Follow the WeChat public account to get more latest article information, thank you for your support

image

Guess you like

Origin blog.csdn.net/u011426115/article/details/112123908