Skip to content

Android Development Environment

Mihai PLESA edited this page Aug 4, 2025 · 8 revisions

System Requirements

Before you begin, ensure your system satisfies the system requirements.

Install additional build dependencies

You will need Git v2.41+, Python 3 and Node.js v20+. You may need to make python3 the default if Python 2.7 is default for your OS. Also, if you don't have anything named python on your machine and only have python3, you will need something like python-is-python3.

If you are using Ubuntu, additionally install:

apt-get install build-essential python-setuptools python3-distutils

You are now ready to clone and initialize this repo. After npm run init is finished, there is one final step to finish installing build dependencies. This shell script only works on Debian and Ubuntu but check system requirements for other distros:

./src/build/install-build-deps.sh --android # for Android

You might also want to try ./src/build/install-build-deps.sh --unsupported if above command gives an error about using a non supported Linux distribution.

Build Acceleration

Developers who work at Brave can find more information on remote build execution here

Build Configuration

Please refer to this document for information about configuring your .env for building Brave.

Sync and build

npm run sync -- --target_os=android
npm run build -- --target_os=android

Troubleshooting

Please check upstream Checking out and building Chromium for Android on Linux build instructions before filing an issue.

Known issues

On debug build for Android lint may crash with error java.lang.OutOfMemoryError: Java heap space. The solution is to set the following environment variable export JAVA_OPTS="-Xmx10G -Xms1G".

Making debug build for Android

In order to make sure the output format is apk, add --target_android_output_format=apk to build command:

npm run build -- Debug --target_os=android --target_arch=arm --target_android_output_format=apk

To change target SDK level, add --target_android_base, e.g.:

npm run build -- Debug --target_os=android --target_arch=arm --target_android_output_format=apk --target_android_base=mono

Installing a build on Android

Both for devices and if you have a started emulator:

./src/build/android/adb_install_apk.py ./src/out/android_Debug_x86/apks/Bravex86.apk

Or

adb install ./src/out/android_Debug_x86/apks/Bravex86.apk

If you have an aab file:

bundletool build-apks --connected-device --bundle=out/android_Debug_x86/apks/Bravex86.aab --output=out/android_Debug_x86/apks/Bravex86.apks
bundletool install-apks --apks=out/android_Debug_x86/apks/Bravex86.apks

Getting crash dumps for Android

adb logcat -d | third_party/android_platform/development/scripts/stack --output-directory out/android_Component_arm

Other debugging instructions for Android

https://chromium.googlesource.com/chromium/src/+/master/docs/android_debugging_instructions.md

Working with WSL(Windows Subsystem for Linux) on Windows

This document provides helpful links and guidance for working with WSL (Windows Subsystem for Linux) when developing Android apps on Windows.

WSL Installation

Easier ADB Integration on WSL2

You can simplify ADB usage in WSL2 by leveraging the Windows-installed ADB executable.

Assuming ADB is installed on Windows and located at:

/mnt/c/platform-tools/adb.exe

And your WSL2 ADB path is:

/usr/bin/adb

You can back up the WSL2 ADB and create a symbolic link to the Windows version:

# Backup existing ADB
sudo mv /usr/bin/adb /usr/bin/adb_bk

# Link Windows ADB into WSL
sudo ln -s /mnt/c/platform-tools/adb.exe /usr/bin/adb

Another option is to make Linux ADB interact with Windows ADB via socket

  1. First, ensure ADB server is running on Windows:

    adb kill-server
    adb nodaemon server -a
  2. Allow ADB through Windows Firewall via PowerShell with administrator privileges:

    New-NetFirewallRule -DisplayName "ADB WSL Connection" -Direction Inbound -Protocol TCP -LocalPort 5037 -Action Allow
  3. Add the following line to your WSL shell configuration file (e.g., ~/.bashrc):

    export ADB_SERVER_SOCKET=tcp:$(ip route | grep default | awk '{print $3; exit;}'):5037

    This command configures WSL to connect to the ADB server running on your Windows host machine by:

    • Getting the Windows host IP address (using ip route)
    • Connecting to the default ADB port (5037)
  4. Apply the changes by either:

    • Restarting your terminal
    • Or running: source ~/.bashrc

Opening Projects in WSL

Fixing VSCode Indexing in WSL

If you're using VSCode and indexing for the WSL project is not working, follow these steps:

  1. Press Ctrl + Shift + P
  2. Search for settings json
  3. Select Preferences: Open Remote Settings (JSON) (WSL:Ubuntu)
  4. Add the following to the settings JSON:
{
  "search.useIgnoreFiles": false,
  "search.useGlobalIgnoreFiles": false,
  "search.followSymlinks": true
}
  1. Relaunch VSCode to apply the changes.
Clone this wiki locally