Building Android 11 for PH-1 on Apple Silicon

My Environment

  • Device: MacBook Air (M1, 2020)
  • OS: macOS Big Sur 11.1 (20C69)
  • Chip: Apple M1
  • Memory: 16GB
  • Device: Essential PH-1(mata)

Install Xcode and Tools

$ xcode-select --install
  • Install Rosetta with:
$ /usr/sbin/softwareupdate --install-rosetta

Creating a case-sensitive disk image

$ hdiutil create -type SPARSE -fs 'Case-sensitive Journaled HFS+' -size 350g ~/forest.dmg

Configure ZSH

nano ~/.zshenv
# set the number of open files to be 2048ulimit -S -n 2048# Compiler cacheexport USE_CCACHE=1# Mount the Android Treefunction mountForest { hdiutil attach ~/forest.dmg.sparseimage -mountpoint /Volumes/Forest; }#Unmount the Android Treefunction umountForest() { hdiutil detach /Volumes/Forest; }
export PATH="/opt/local/bin:/opt/local/sbin:$PATH"export PATH=~/.bin:$PATH

Download AOSP source code

$ source ~/.zshenv
$ mkdir ~/.bin
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/.bin/repo
$ chmod a+x ~/.bin/repo
$ mountForest
$ cd /Volumes/Forest
$ mkdir aosp_mata
$ cd aosp_mata

$ git config --global user.name "Your Name"
$ git config --global user.email "you@example.com"

$ repo init -u https://android.googlesource.com/platform/manifest -b android-11.0.0_r3
$ repo sync
$ mkdir -p device/essential$ cd device/essential$ git clone https://github.com/EssentialOpenSource/device_essential_mata.git mata$ cd ../../
$ cd system/sepolicy
$ git revert 61178550157fce18861ddd59fa9a6a29cf06c583
$ cd ../../
$ cd device/essential/mata
$ curl -o vendor.zip "https://storage.googleapis.com/essential-static/vendor-QQ1A.200105.088.zip"
$ unzip vendor.zip
$ rm -f vendor.zip
$ cd ../../../

Fix the Build for OS X

  • /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/
namespace base {size_t psize = getpagesize();ssize_t SendFileDescriptorVector(borrowed_fd sockfd, const void* data, size_t len,
if (cmsg_space >= psize) {

Build AOSP

$ source build/envsetup.sh
$ lunch mata-userdebug
$ make -j4

Flash to Device

$ nano ~/.zshenv
export PATH=~/.bin/platform-tools:$PATH
$ source ~/.zshenv
$ adb reboot bootloader
$ cd $OUT
$ fastboot flash:raw boot_a boot.img
$ fastboot flash:raw boot_b boot.img
$ fastboot flash system_a system.img
$ fastboot flash system_b system.img
$ fastboot flash vendor_a vendor.img
$ fastboot flash vendor_b vendor.img
$ fastboot erase userdata
$ fastboot reboot
$ croot

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How I improved UDP Server’s processing performance from 900 msg/sec to 9000 msg/sec

Soft Deletion in Ruby on Rails

The impact of the Curve 4pool on the stability of the UST peg

Dynamic Web Table Handling in Selenium

Creating a Factory Automation Game With Unity in Three Days for Ludum Dare

Cloudbot 101 — Loyalty Points

Swift LeetCode #9

[Java] Find and Replace Text in Word Documents

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Nick Franco

Nick Franco

More from Medium

iOS Vs Android Development: Which Do You Go For?

WHICH ONE TO CHOOSE: FLUTTER OR NATIVE?

Android 13 Beta Installation on Google Pixel and Non-Pixel Devices

Android 13 Beta Installation on Google Pixel and Non-Pixel Devices

How to Lock Instagram Chats on Android