We have moved to a new Sailfish OS Forum. Please start new discussions there.

[HowTo] Install Google Play Services on baseport 8 devices from the phone itself (Tested working)

asked 2019-05-12 22:31:26 +0300

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

updated 2019-06-03 12:09:08 +0300

Giacomo Di Giacomo gravatar image

This guide provides a simple procedure to create a version of system.img including the pico version of opengapps (Google Play Services). This requires only the phone itself, used as a Linux box, and possibly a PC to transfer files to it via USB (but you can anyway edit and download files from the phone). This procedure was developed and tested by @Artur.

First of all, enable developer mode. All the procedure is run from the phone's command line shell. Work as root by issuing the command devel-su and entering the root password you set when you enabled developer mode.

Secondly, install the required elements that will be using to create a modified version of system.img. As a working directory, you can create a subdirectory of /home/nemo/Downloads, or you can use a directory on your SD card. Let's call our directory the "Work directory".

  1. Install lzip and a version of squashfs-tools with lz4 support:

    pkcon install info
    rpm -i https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/22/Everything/armhfp/os/Packages/l/lzip-1.16-1.fc22.armv7hl.rpm
    rpm -i https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/22/Everything/armhfp/os/Packages/l/lz4-r128-2.fc22.armv7hl.rpm 
    rpm -U --oldpackage --nodeps https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/22/Everything/armhfp/os/Packages/s/squashfs-tools-4.3-8.fc22.armv7hl.rpm
  2. Stop Android Support from Settings -> Android Support. Run devel-su rm -rf /home/.android/*; this will uninstall all your current Android applications and remove their data. This is useful to avoid weird things happening.

  3. Create an install_opengapps.sh script with the following content, or download it from the link at the bottom, and make it executable with the command chmod 755 install_opengapps.sh. You can copy the text from a PC and move it to the phone via USB; if you do so, take care to open the file in TinyEdit (or any other editor) on the phone and save it again; this will convert the stupid Microsoft-style newlines in proper ASCII newlines.

    set -e
    google_remove='carriersetup extservicesgoogle extsharedgoogle googlebackuptransport googlecontactssync googlefeedback googlepartnersetup'
    if [ -f system.img.orig ]; then
        echo 'WARNING: reusing existing system.img.orig' >&2
        cp /opt/alien/system.img system.img.orig
    unsquashfs system.img.orig
    unzip "$opengapps_zip" -d opengapps/
    for p in $google_remove; do
        rm "opengapps/Core/$p-all.tar.lz"
    if [ -f opengapps/Core/extservicesgoogle-all.tar.lz ]; then
        rm -r squashfs-root/system/priv-app/ExtServices
    if [ -f opengapps/Core/extsharedgoogle-all.tar.lz ]; then
        rm -r squashfs-root/system/app/ExtShared
    rm opengapps/Core/setupwizardtablet-all.tar.lz
    mkdir opengapps_2
    for f in opengapps/Core/*.tar.lz; do
        lzip -c -d "$f" | tar -x -C opengapps_2
    cp -r opengapps_2/*/*/* squashfs-root/system/
    rm -f system.img.gapps
    mksquashfs squashfs-root system.img.gapps -comp lz4 -Xhc -noappend -no-exports -no-duplicates -no-fragments
    rm -r opengapps opengapps_2 squashfs-root
  4. Download opengapps for Android 8.1 from www.opengapps.org; choose the pico version for the ARM64 architecture (ARM will work anyway).

All of this should be done only once on your phone.

Now you should patch the system.img file; this must be done after all Sailfish OS updates. Do the following:

1. Stop Android support if it is running. Run install_opengapps.sh as root and pass the opengapps zip as a parameter (e.g. devel-su ./install_opengapps.sh ./Downloads/open_gapps-arm-8.1-pico-20190508.zip). If you are updating your system and you get a message about lack of lz4 support, this means that Sailfish now includes a version of squashfs-tools without this support. To overcome this, just install it again by executing again the last line in step 1 of the preliminary procedure above.

(Running as root is necessary for unsquashfs to create files with the correct permissions when it unpacks the image.)

2. Copy system.img.gapps to /opt/alien/system.img.

3. Start Android support. If you are successful, in few minutes the Android setup screen should appear. Skip network configuration and finish the setup. In a few seconds you should get a notification about Google Play Protect. Click the notification and disable Play Protect. (If you miss it, open Google Play Store and check the three-dot-menu for the option; if the option is not there, close Play Store, wait a few minutes, and try again.) Please note that this does not solve the issue of Google Play Store refusing downloads: you won't be able to download apps using Google Play Store in any case. You will need to use Yalp Store or another Android store.

edit 20.5.2019: Downloads from Google Play Store seem to work with mobile connection (

  1. Install the Aptoide store from Jolla Store (if it is already installed, uninstall and install it again), then make sure you can open it. If the icon disappears, wait a few minutes.

    (This step is intended for testing if you can install Android applications, even if you want to uninstall Aptoide afterwards.)

In case you want to put things back as they were, you can find the original system.img file as system.img.orig in your Work directory.

ready script to use install_opengapps.sh.zip

edit retag flag offensive close delete



Suggested edits by a moron who initially did most of it wrong:

In 1, the command lines presentation is a tad confusing. Could the separate rows for each file be in separate boxes?

In 2, if you don't know code at all you can easily mistake to think that the command line does the stopping of Android Support. You need to do that from the Settings app.

In 3, please include the command line to make the sh file executable so that doesn't get lost in text.

In 4, please mention it's specifically Android 8.1 we need. I believe using the newest 9 would be a huge mistake.

In the second 3, please mention that downloading from Google Play doesn't seem to work, and as such you don't really need to and shouldn't sign up to your Google account during the configuration. The Play Services will work either way.

teemu ( 2019-05-12 23:00:48 +0300 )edit

@teemu It's a wiki, so you or whoever else can edit based on own results in order to clarify and possibly correct the howto. Anyway I will try to improve it myself based on your suggestions. Feel free to add your edits.

Giacomo Di Giacomo ( 2019-05-13 00:41:33 +0300 )edit

Strange that someone remove my link to final script to use -.-

Ahhh and remember if something go wrong, before next use you must remove opengapps, opengapps_2 and squash-root directory

Stanislav1988 ( 2019-05-13 06:22:04 +0300 )edit

@Giacomo I'm a bit wary to presume editing myself, I rather other people re-check my suggested edits for factuality.

Do I really have to do this again after every Sailfish OS update? I have installed Google Play Services by following the previous instructions posted on Jolla Together with older Android/Sailfish versions, and never had any trouble with the Android/Play Services functionality after a Sailfish OS update.

Is the situation different now because of there being expected updades in the Android Support (which at this point still is beta on XA2)? The Play Services probably will remain installed, but will the future Android-related updades mess up something that will effect on them?

I'm not looking to re-re-install every Android app every time.

teemu ( 2019-05-13 15:12:57 +0300 )edit

@teemu Yes. The problem is that now the Android system lies within a single compressed file (system.img). Otherwise there would not have been the need for all this stuff, we should just have copied the new files in the right places.

Giacomo Di Giacomo ( 2019-05-13 16:26:26 +0300 )edit

13 Answers

Sort by » oldest newest most voted

answered 2019-08-09 13:25:43 +0300

ehakkarainen gravatar image

updated 2019-08-09 13:26:17 +0300

Getting stuck (loop?) in the Android setup phase "Checking information" (in Finnish "Tarkistetaan tietoja") - any advice?

edit flag offensive delete publish link more


skip all steps in window, and add account after skip all this steps

Stanislav1988 ( 2019-08-09 14:06:36 +0300 )edit

Hi. After install .sh do it:

rm -rf /home/.android/*

Else skip all steps in window, and finish. After open Play Store and add the acocunt

Rafaelvlmendes ( 2019-08-09 19:20:50 +0300 )edit

Did someone try this procedure using the above script for sfos for xa2? Are you able then to run the youtube app, which requires google play services to work?

xidira ( 2019-08-15 00:13:16 +0300 )edit

@xidira yes. All fun and the apps all right.. I want create a new tutorial. If you have questions I send here

Rafaelvlmendes ( 2019-08-15 01:16:50 +0300 )edit

answered 2019-08-27 06:56:47 +0300

babo gravatar image

updated 2019-08-27 08:32:09 +0300

Ever since the 3.1 update, im trying to make that work.Everything goes as expected and I finish the setup.However, when I try to log into google (through playstore or settings) it doesn't work and I get this :

image description

Appreciate any help

edit flag offensive delete publish link more


Have you tried on both mobile connection and on wifi?

I at least still have ongoing issues on 3.1 with Android apps that seem to seemingly randomly and without logic fail to work either with mobile or wifi but with the other connection will work without problems.

The app won't even communicate to me that it's not doing anything because of "no internet connection", but when trying with other connection it will work like there never was a problem.

teemu ( 2019-08-27 10:55:18 +0300 )edit

I can confirm this. Get the same message on XA2 with SailfishOS 3.1 and wifi connection.

MaxT ( 2019-08-27 12:34:24 +0300 )edit

@teemu Yes I have tried both connections, even tried it with VPN. Everything Android-related works fine

babo ( 2019-08-27 12:36:28 +0300 )edit

When you say Settings, do you mean:

  1. Settings - Accounts (the Sailfish OS side of things), or

  2. the Android side settings at Settings - Apps - [any Android app] - Open Android Settings - [back button to main Android settings] - Users and Accounts?

edit: 3. Or the gray cogwheel iconed Google Settings app?

teemu ( 2019-08-27 14:47:14 +0300 )edit

Hey but hey!

As the debugging should work now, you can access the Android logs on the Terminal by:

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

Open the logging as devel-su and leave it running, then try to sign to Play and see from the log what fails to happen.

Further reading: https://together.jolla.com/question/204859/how-to-help-debug-android-support/?answer=204871#post-id-204871

teemu ( 2019-08-27 14:58:57 +0300 )edit

answered 2019-12-21 21:07:32 +0300

Jowe gravatar image

will this tutorial and/or script work on an Android 9 base with Sailfish X version on an Xperia 10?

If not, what adaptations must be made?

Thank you for all of your hard work on this!

edit flag offensive delete publish link more



I don't have an Xperia 10 to test. Try it. In the worst case you can reinstall Aliendalvik.

Artur ( 2019-12-21 21:47:24 +0300 )edit

Awesome. Thanks. I'll report back and let you know what I find out.

Jowe ( 2019-12-21 22:04:53 +0300 )edit

The short answer is it didn't work perfectly. I updated your script to download the correct gapps (Android 9) and installed it. It did install google play store. It did however force close the store right after starting it. I was also getting an error about updating the store if I remember correctly. I can investigate further for science after dinner.

Jowe ( 2019-12-21 23:01:29 +0300 )edit

Thanks for the feedback. So Aliendalvik for the 10 is actually Android 9?

I didn't use Play Store, iirc I always disabled it. Now I'm using MicroG and no Google Apps at all. Might try to debug the script's current status next month.

Artur ( 2019-12-24 03:25:13 +0300 )edit


I have also now a Sony Xperia 10 with SFOS I came from Jolla C and miss now the google play services for some apps (ZÄPP, my DVG). Bedcause I want to try this but in Salfish X the folder '/opt/alien/system/priv-app/' not exist now. Follow way I wan't to try, but I am affraid that the Phone need a factory reset after it.

"password" ENTER
systemctl stop aliendalvik.service
systemctl mask aliendalvik.service
#copy the 4 files withe root file explorer to the directory /opt/alien/system/priv-app/
#(GmsCore.apk, GoogleLoginService.apk, GoogleServicesFramework.apk, Phonesky.apk)
systemctl unmask aliendalvik.service
systemctl start aliendalvik.service
apkd-install Phonesky.apk

The 4 files are in the zip file from here in the folder: "gapps-kk-20140606-signed\system\priv-app".

Could you help me with this easy way. I have no linux pc. It is possible to open the system.img file to add the 4 files? Or it is possible to install the 4 files manually?

Thanks for your answer in advance

Ralf ( 2019-12-29 13:24:07 +0300 )edit
Login/Signup to Answer

Question tools



Asked: 2019-05-12 22:31:26 +0300

Seen: 8,076 times

Last updated: Dec 21 '19