Building Your Own Android Firmware
Summary
This guide explains how to compile a custom Android firmware image from source for the Banana Pi and Banana Pro. Building from source allows you to customise the system, add or remove packages, apply patches, and stay up to date with the latest fixes.
Who This Is For
Advanced users and developers with Linux command-line experience who want to create a tailored Android build for their Banana Pi or Banana Pro board.
What You Will Do
- Set up a build environment on an Ubuntu host.
- Download the Android source tree.
- Configure the build for the Banana Pi target.
- Compile the firmware and flash it to an SD card.
Prerequisites
- Host OS: Ubuntu 18.04 or 20.04 LTS (64-bit) recommended.
- Disk space: At least 100 GB free (the source tree and build output are large).
- RAM: 8 GB minimum, 16 GB recommended.
- JDK: OpenJDK 8 (required by the Android build system).
- Build tools:
git,curl,make,gcc, and various libraries.
Step-by-Step Procedure
Step 1 — Install Dependencies
sudo apt update
sudo apt install -y openjdk-8-jdk git curl gnupg flex bison \
build-essential zip unzip libncurses5-dev libssl-dev \
x11proto-core-dev libx11-dev libgl1-mesa-dev libxml2-utils \
xsltproc python3 python-is-python3 repo
If repo is not available from APT, install it manually from Google's repository.
Step 2 — Initialise the Source Repository
mkdir ~/banana-android && cd ~/banana-android
repo init -u https://github.com/nickholtus/BananaPi-Android-4.2.2-Liab.git -b master
repo sync -j4
The sync may take several hours depending on your internet speed. The full source tree is approximately 30–50 GB.
Step 3 — Configure the Build Target
source build/envsetup.sh
lunch
Select the Banana Pi target from the menu. The exact target name depends on the source tree but is typically bananapi-eng or bananapi-userdebug.
Step 4 — Build the Firmware
make -j$(nproc)
A full build takes 1–3 hours depending on your hardware. When complete, output images are placed in out/target/product/bananapi/.
Step 5 — Pack the Image
The Allwinner Android image must be packed into a format the board can boot. Use the PhoenixCard tool (Windows) or sunxi-pack scripts to create a flashable image:
./build.sh pack
This produces a single .img file that contains U-Boot, the kernel, and the Android system partition.
Step 6 — Flash to SD Card
On Linux, use dd to write the packed image:
sudo dd if=out/bananapi_android.img of=/dev/sdX bs=4M status=progress conv=fsync
On Windows, use PhoenixCard to select the image and write it to the SD card in Startup mode.
Step 7 — Boot and Test
Insert the card into the board, connect HDMI, and power on. The Android boot animation should appear after 30–60 seconds. First boot may take longer as the system optimises applications.
Verification
Once Android has booted, open Settings → About to confirm the build version matches your custom build. Connect to WiFi or Ethernet and verify basic functionality.
Common Build Errors and Fixes
- JDK version mismatch: Android 4.x requires JDK 8. Set
JAVA_HOMEto the JDK 8 path. - Out of memory during build: Increase swap space or reduce parallel jobs (
make -j2). - Missing libraries: Install any missing packages reported in the error output. Check the AOSP requirements page for a complete list.
- repo sync failures: Retry with
repo sync -f -j2to continue past transient network errors. - Image does not boot: Verify you used the correct pack script and the correct
ddtarget device.
Related Pages
Author: LeMaker Documentation Team
Last updated: 2026-02-10