Skip to content

Instantly share code, notes, and snippets.

Last active Jan 5, 2022
What would you like to do?
Google Play Services installation to Sailfish X

Google Play Services for Alien Dalvik in Sailfish OS

Devices I have tested the guide:

  • Xperia 10 II
  • Currently not working: Xperia XA2


You need unzip, wget and squashfs-tools.

If you have Debian/Ubuntu/etc. run the following:

sudo apt install unzip wget squashfs-tools


In the host Linux machine

  • retrieve OGApps ARM / 10.0 / pico from:

    • Xperia 10 II: ARM64 / Android 10.0
    • Xperia XA 2: ARM / Android 10.0 (interestingly, the hardware supports 64bit..)

    Sailfish 3+ use Android 8.1, Sailfish 4.0 use Android 9.0, and sailfish 4.1+ use Android 10.0

  • download also md5 checksum

  • copy /opt/alien/system.img to a Linux, e.g.:

    scp defaultuser@PHONE_IP:/opt/alien/system.img .

    The username is nemo for old installations.

  • rename file, so we keep the original

    mv -i system.img system-original.img`
  • extract required apps and support files, i.e, run the following in bash/zsh/ksh:

zip=$(ls open_gapps-arm*-*-pico-*.zip | sort -rn -k3,5 -t- | head -n1)
md5sum -c "$zip.md5"
mkdir -p to-system/
for f in \
    Core/defaultetc-common.tar.lz \
    Core/defaultframework-common.tar.lz \
    'Core/gmscore-*.tar.lz' \
    Core/gmssetup-all.tar.lz \
    Core/googlebackuptransport-all.tar.lz \
    Core/googleonetimeinitializer-all.tar.lz \
    Core/googlepartnersetup-all.tar.lz \
    Core/gsfcore-all.tar.lz \
    'Core/setupwizarddefault-*.tar.lz' \
    'Core/vending-*.tar.lz' \
    ; do
  echo ".. $f:"
  unzip -p "$zip" "$f" | tar -vx --lzip --strip-components 2 -C to-system/
# remove execute from data files
find to-system/ -type f -print0 | xargs -r0 chmod -x
# extract shared libs
if [ "$zip" = "${zip#*-arm64-}" ]; then native=armeabi-v7a; else native=arm64-v8a; fi
for apk in to-system/priv-app/*/*.apk; do
  pushd "${apk%/*}"
  rm -rf lib/*/
  unzip -x "${apk##*/}" "lib/$native/*"
  [ -e lib/armeabi-v7a ] && mv lib/armeabi-v7a lib/arm
  • optionally, you can include Aurora Store as system app at this point (fork of YalpStore)

    Google Play store works with Xperia 10 II, so if you prefer that, no need to install this.

    mkdir -p to-system/priv-app/AuroraStore
    wget '' -O to-system/priv-app/AuroraStore/AuroraStore.apk
    echo "83dc14d53cc0ac188c9bf1613f84e5bbc8046fed260e38a47a28811eb28f820a to-system/priv-app/AuroraStore/AuroraStore.apk" | sha256sum -c

    If the last line, doesn't say OK, then there was a problem with the download, do not use the image! .

  • open squashfs image, fix, copy apps and repackage (requries squashfs-tools)

    NOTE: If you find a better method to keep file owners and permissions than sudo, let me know!

    sudo bash -c "
      # unpack
      unsquashfs -d \$root system-original.img
      # fix broken files
      chmod +r \$root/system/etc/fs_config_dirs \$root/system/etc/fs_config_files
      # copy
      cp -vr to-system/* \$root/system/
      # repackage
      mksquashfs \$root/ system.img -comp lz4 -Xhc -noappend -no-exports -no-duplicates -no-fragments
      # clean
      chown $USER.$(id -ng) system.img
      rm -rf \$root
  • upload image scp system.img nemo@PHONE_IP:/home/nemo/

  • cleaup rm -rf to-system system.img (note: let's keep original-system.img as a backup)

In your phone, e.g. ssh nemo@PHONE_IP. Remember to be a root devel-su.

  • Install the new image:

    # stop alien
    systemctl stop aliendalvik
    # backup system.img
    cp /opt/alien/system.img /home/alien-system.img
    # replace it
    cp /home/nemo/system.img /opt/alien/system.img
    # clear system app cache
    rm -vrf /home/.android/data/system/package_cache/*/Settings-*
    # remove updated google apps
    rm -vrf /home/.android/data/app/*
    rm -vrf /home/.android/data/app/*
    # fix android bootup with Sailfish 4.1
    rm -vrf /home/.android/data/misc/audioserver/
    # you can start alien now
    systemctl start aliendalvik
  • Note that startup after the installation will take a long time as the Android is caching and compiling files. You can follow the progress with the following command. However, it will show a lot of errors and warnings, so it might be alarming, even though everything is ok.

    lxc-attach -n aliendalvik -- /system/bin/logcat

When you install google play services for the first time:

  • open google play and sign in

  • retrieve GSF ID:

    Sadly, neither Sailfish 4 or Android contains sqlite3 anymore, so you need to do some manual work.

    # on sailfish after devel-su
    cp /home/.android/data/data/ /tmp/
    chmod a+r /tmp/gservices.db
    # on your computer
    scp defaultuser@PHONE_IP:/tmp/gservices.db
    sqlite gservices.db 'select * from main where name = "android_id";'
    # copy the id from the output
    rm gservices.db
    # on sailfish after devel-su
    rm /tmp/gservices.db
  • Register your device:

Known issues:

  • Fast location doesn't work with wi-fi polling
  • Google Play Store can't install applications. Seems android biometric interface is not implemented
    • Works in Xperia 10 II, SFOS 4.2, Android 10
  • Google Backup Transport doesn't seem to work (requires investication)


  • for location service, disable google wi-fi checking, it doesn't work. This means that accurate location will take some time, of course (e.g. Jodel will take few minutes to login).

  • when aliendalvik is running, you can stream android logs with

    lxc-attach -n aliendalvik -- /system/bin/logcat
  • If google backup is disabled, you can re-enable it:

    lxc-attach -n aliendalvik -- /system/bin/sh # enter Android shell
    bmgr transport # in Android system
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment