Android development on FreeBSD

22 Nov 2018 - tsp
Last update 18 Dec 2019

Note: The following method does not work any more! It’s to my knowledge not possible to circumvent aapt2 during the build process and not possible to run the binary (not even with the binary compatibility layer because it gets downloaded by gradle every time so branding doesn’t work). I’ve given up on using Android Studio on FreeBSD and went on to run it on a remote Linux VM and use X11 forwarding.

Note that the following instructions require Java to be installed already. Java is available via the java/openjdk8 port or package.

There are three parts to development on FreeBSD:

Note that FreeBSD is not a supported platform so things may break or not work as fluently as on other platforms. Another thing to note is that most tools that are implemented as shell-scripts may need modification (simply changing #!/bin/bash to #!/bin/sh is enough most of the time, don’t ask why they’ve used bash in the first place)

Installing the CLI tools and SDKs

Download and unzip android SDK (cli tools), extract (unzip) …

cd tools

And install the SDKs you want to use. Available SDKs can be listed with

./sdkmanager --list
./sdkmanager --install "platforms;android-26"
./sdkmanager --install "platforms;android-18"
./sdkmanager --install "platforms;android-10"
./sdkmanager --install "extras;google;m2repository"
./sdkmanager --install "extras;google;google_play_services"
./sdkmanager --install "extras;android;m2repository"
./sdkmanager --install "docs"

Installing ADB and Fastboot

These are available via ports/packages at devel/android-tools-adb and devel/android-tools-fastboot and can be installed either via

pkg install devel/android-tools-adb
pkg install devel/android-tools-fastboot

or via

cd /usr/ports/devel/android-tools-adb
make install && make clean
cd /usr/ports/devel/android-tools-fastboot
make install && make clean

Android Studio

First download and extract the zip file to an appropriate location


Add to android-studio/bin/`

Then one can launch (and really use) Android Studio via


Note that some features like additionally loaded binary tools by gradle require the linux and linux64 compatibility layers loaded into the kernel. Also note that you have to configure your projects to use the JRE from the JDK at /usr/local/openjdk8 and not the bundled one (you might encounter that problem if the initial gradle sync fails)

This article is tagged:

Data protection policy

Dipl.-Ing. Thomas Spielauer, Wien (

This webpage is also available via TOR at http://jugujbrirx3irwyx.onion/

Valid HTML 4.01 Strict Powered by FreeBSD IPv6 support