banner
fwrite

fwrite

好好生活
twitter
github
email

Android Source Code Compilation

Use apt to install the following tools

  sudo apt upgrade
  sudo apt update
  
  sudo apt install -y \
      vim \
      git-core \
      gnupg \
      flex \
      bison \
      gperf \
      build-essential \
      zip \
      unzip \
      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 \
      libncurses5 \
      libelf-dev \
      libswitch-perl

Install Google's repo tool to download Android source code and Android kernel code
Download and install the repo tool

  mkdir ~/bin
  PATH=~/bin:$PATH
  curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
  chmod a+x ~/bin/repo

Download Source Code#

  mkdir android_source && cd android_source

Make sure to set up basic git information, name, email

  git config --global user.name <Your Name>
  git config --global user.email <you@example.com>

repo init: specify the url & branch you want to download (branch name can refer to the official documentation)

  repo init -u https://android.googlesource.com/platform/manifest \
      -b android-13.0.0_r1
  repo sync

Compile Android#

Initialize the environment: run the following command in the root folder of the downloaded Android

  cd ~/android_source
  
  source ./build/envsetup.sh

lunch select build target: choose the target to compile, the format consists of BUILD, BUILDTYPE
Build refers to the platform to run after compilation

BUILDTarget DeviceNotes
FullEmulatorFull compilation, includes all languages, apps, input methods, etc.
full_manguromanguroFull compilation, runs on Galaxy Nexus GSM/HSPA+("manguro")
full_pandapandaFull compilation, runs on PandaBoard("panda")

BUILDTYPE is divided into three types

BUILDTYPEFeatures
userVersion released to the market, defaults without root access, adb disabled
userdebugOpen root, adb access, generally used for real device debugging
engHas maximum permissions (root), and has additional debugging tools, generally used for emulator

make compile: can compile according to the number of CPU cores on your computer

  # make -j$(nproc)
  
  make -j10

Android Source Single Compile - Module#

In addition to full compilation, we can use single compile for a specific application module (e.g., Settings application module)
In the root directory of Android Source, execute the following command

  source ./build/envsetup.sh
  
  lunch xxx

Enter the Settings directory and use mm to compile

  mmm packages/apps/Settings

In addition to the mm command, other commands can also be used for single compilation

CommandFunction
mmCompile the Module in the current directory (must enter the specified project directory to compile)
mmmCompile the Module in the specified directory, but do not compile its dependent Modules (can compile any specified project in any level of the Android source code directory structure)
mmaCompile the Module in the current directory, including its dependent Modules
mmmaCompile all Modules in the specified path, including their dependencies

Run Emulator#

  source ./build/envsetup.sh
  
  lunch xxx
  
  emulator
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.