Link Search Menu Expand Document

Sailfish X Xperia Android 8 Build and Flash

Sailfish OS Hardware Adaptation Development Kit for Sony Xperia XA2

Here you will find instructions how to build Sailfish OS image and flash it to Sony Xperia XA2 device.


  • 2020-06-16: Align with the latest build scripts
  • 2019-03-15: More community contributions taken in to de-clutter the build process, and align with HADK 3.0.1
  • 2019-03-05: Cleaned up packages that do not gracefully install under the Platform SDK target, thanks to community’s contributions to the helper build scripts!
  • 2019-03-01: Adapt from Xperia X flash and build instructions


Please download the latest Sailfish OS HADK (Hardware Adaptation Development Kit) from within this link.

Minimum Sailfish OS version for this port is

If you are new to HADK, please carefully read the disclaimer on page 1, then chapters 1 and 2.

The disk space requirement for this build is not 16GB as HADK says, but around 90GB . The download bandwidth requirement is around 30GB.

HADK uses CyanogenMod as reference base. Here we’ll instead have Sony’s stock Android (8.1.x). Now you can read through chapter 3 of the HADK.

If you ever run into difficulties, we’re there to help in the #sailfishos-porters channel on IRC at

In chapter 4 (Setting up the SDKs) setup the environment in ~/.hadk.env with additional variables (here we’ll build for Sony Xperia XA2 Dual SIM variant):

export VENDOR=sony
export DEVICE=h4113
export HABUILD_DEVICE=pioneer
export FAMILY=nile
export BRANCH=8.1.0_r52
export HAVERSION="sony-aosp-"$BRANCH"_20190206"

Follow through the chapter 4 until the end, and ignore chapter 5, instead perform the following:


git config --global "Your Name"
git config --global ""

You’ll need to ensure you have the repo command from the AOSP source code repositories installed. See the Android Source instructions for how to install it. Once available you can continue:


sudo apt-get install cpio libssl-dev
sudo mkdir -p $ANDROID_ROOT
sudo chown -R $USER $ANDROID_ROOT
repo init -u -b hybris-$HAVERSION -m tagged-manifest.xml
# Adjust X to your bandwidth capabilities
repo sync -jX --fetch-submodules
source build/
export USE_CCACHE=1
lunch aosp_$DEVICE-user
git clone external/droidmedia
make -j$(nproc --all) hybris-hal droidmedia

If you encounter errors, check with HADK’s section 5.5 “Common Pitfalls”, and if it’s not there, ask us on IRC.

Once you have hybris-boot.img and hybris-recovery.img files successfully built, go through chapter 6 of the HADK document.

Ignore chapter 7, but do the following instead:


sudo zypper ref
rpm/dhd/helpers/ --droid-hal
git clone --recursive$FAMILY hybris/droid-configs -b master
if [ -z "$(grep community_adaptation $ANDROID_ROOT/hybris/droid-configs/rpm/droid-config-$DEVICE.spec)" ]; then
  sed -i '/%include droid-configs-device/i%define community_adaptation 1\n' $ANDROID_ROOT/hybris/droid-configs/rpm/droid-config-$DEVICE.spec
if [ -z "$(grep patterns-sailfish-consumer-generic $ANDROID_ROOT/hybris/droid-configs/patterns/jolla-configuration-$DEVICE.yaml)" ]; then
  sed -i "/Summary: Jolla Configuration $DEVICE/i- patterns-sailfish-consumer-generic\n- pattern:sailfish-porter-tools\n" $ANDROID_ROOT/hybris/droid-configs/patterns/jolla-configuration-$DEVICE.yaml
rpm/dhd/helpers/ --configs
rpm/dhd/helpers/ --mw # select "all" option when asked

After all’s built, proceed with:


rpm/dhd/helpers/ --gg

sdk-assistant maintain $VENDOR-$DEVICE-$PORT_ARCH zypper in --force-resolution droid-hal-$HABUILD_DEVICE-kernel-modules
rpm/dhd/helpers/ --mw=$FAMILY --spec=rpm/droid-hal-$HABUILD_DEVICE-img-boot.spec

rpm/dhd/helpers/ --mw=$FAMILY-$HABUILD_DEVICE --spec=rpm/droid-system-$HABUILD_DEVICE.spec --spec=rpm/droid-system-$HABUILD_DEVICE-$DEVICE.spec
rpm/dhd/helpers/ --mw=$FAMILY-$HABUILD_DEVICE --spec=rpm/droid-system-vendor-$HABUILD_DEVICE.spec --spec=rpm/droid-system-vendor-$HABUILD_DEVICE-$DEVICE.spec

git clone --recursive$FAMILY hybris/droid-hal-version-$DEVICE
rpm/dhd/helpers/ --version

Next, please proceed with:


export RELEASE=
export EXTRA_NAME=-my1
sudo zypper in lvm2 atruncate pigz
sudo zypper in android-tools
rpm/dhd/helpers/ --mic

If you want to rebuild your image again later, umount any /var/tmp/mic/imgcreate-*/ mounts manually.

The command above will yield a flashable archive, such as $ANDROID_ROOT/sfe-h4113- that you will use to flash your device as explained in the next section.


All the instructions you will find on our website (yet use your own built .zip bundle!):

Note: in you will need to replace @DEVICES@ with your $DEVICE value in uppercase, e.g. H4113. Naturally, after that you’ll need to adjust or remove the line containing in the md5.lst file.


If you find bugs while building an image from this page, please report them in our IRC channel.

Have fun and enjoy our first fully-flashable Sailfish OS image built by you! Your Jolla HW Team