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

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

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

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 +0200

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.

    #!/bin/sh
    
    set -e
    
    google_remove='carriersetup extservicesgoogle extsharedgoogle googlebackuptransport googlecontactssync googlefeedback googlepartnersetup'
    
    opengapps_zip="$1"
    
    if [ -f system.img.orig ]; then
        echo 'WARNING: reusing existing system.img.orig' >&2
    else
        cp /opt/alien/system.img system.img.orig
    fi
    
    unsquashfs system.img.orig
    
    unzip "$opengapps_zip" -d opengapps/
    
    for p in $google_remove; do
        rm "opengapps/Core/$p-all.tar.lz"
    done
    
    if [ -f opengapps/Core/extservicesgoogle-all.tar.lz ]; then
        rm -r squashfs-root/system/priv-app/ExtServices
    fi
    if [ -f opengapps/Core/extsharedgoogle-all.tar.lz ]; then
        rm -r squashfs-root/system/app/ExtShared
    fi
    
    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
    done
    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 (3.0.3.9).

  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

Comments

2

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 +0200 )edit
1

@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 +0200 )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 +0200 )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 +0200 )edit
1

@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 +0200 )edit

13 Answers

Sort by » oldest newest most voted
12

answered 2019-06-15 15:42:22 +0200

Artur gravatar image

updated 2019-06-15 17:04:35 +0200

I made a script that automates the entire process, including installing the dependencies and finding the Open GApps zip in your downloads folder (or opening the download page). Needs to be run as root.

Also doesn't break logcat.

https://gitlab.com/artur_gaspar/aliendalvik-systemimg-patcher/blob/master/install_opengapps.sh

Restore the original image to /opt/alien/system.img before using. This is only necessary the first time, then the script will back up the original image and reuse it from there next time.

Optionally, uninstall squashfs-tools and lz4 before running the script (pkcon remove squashfs-tools lz4). This script can work with the squashfs-tools from the default repository instead of the one from Fedora that supports lz4.

edit flag offensive delete publish link more

Comments

Thank you for the great work (again), @Artur.

Two questions:

1) This doesn't include the command devel-su rm -rf /home/.android/ and so doesn't uninstall all Android applications? Should one manually execute that command before doing the initial patching? The Android apps installed with a patched system.img will survive and stay functional after subsequent patchings, but when patching a vanilla system.img should you uninstall the Android apps that were installed without Play Services being present?

2) This will back up the current /opt/alien/system.img that came with Sailfish OS (assumably 3.0.3.10 for most people). When the next update [3.1.0] will replace the patched /opt/alien/system.img, wouldn't running this script use and patch again the old backed-up system.img [3.0.3.10] that is missing the latest Android changes provided by Jolla? Does Jolla actually update the system.img in any meaningful way for it to become an issue?

teemu ( 2019-06-15 21:06:57 +0200 )edit
1

@teemu

1) Good point, I forgot about that. The truth is that I don't really know whether it is necessary to start from a clean Android system when installing Google apps, and I tested with my existing Android data (already with Google apps set up).

2) No. The script saves a file in the images that it modifies. Then it checks for that file on /opt/alien/system.img. If the file doesn't exist, the script assumes that it is an original image and uses that. Only if that file exists the script looks for its backup.

Artur ( 2019-06-16 06:13:05 +0200 )edit

It dont work I try complete config screen of Google Play but it dont let me go to next step when I must choose between copy data or config us new phone, it repeat this step after I add my name, and now I can`t run android support :(

Stanislav1988 ( 2019-07-29 06:22:41 +0200 )edit

ok after some problem finally I have log in buttom but after click it doesn`t work, nothing happen why :(

Stanislav1988 ( 2019-07-29 07:11:13 +0200 )edit

@Stanislav1988 Remove /home/android/.data and try again. Don't log in to Google.

Also check logcat to see what is happening.

Artur ( 2019-08-01 01:41:11 +0200 )edit
4

answered 2019-06-23 15:32:15 +0200

TMavica gravatar image

Guys, wait for sailfish 3.1, there will have MicroG and spoofing signatures support, you can enable them easily

edit flag offensive delete publish link more

Comments

any idea when they will release? where can I find info about whats going to be included in update?

groeable ( 2019-06-23 15:38:59 +0200 )edit

Google music work with microG services?

Stanislav1988 ( 2019-07-21 20:12:52 +0200 )edit

@TMavica:

wrong thread. This question is about installed the actual proprietary blob from Google, so the signature spoofing from 3.1.0 doesn't change anything.

That's the question about microG (and as it is a wiki, I put a link to your HOWTO).

DrYak ( 2019-07-22 04:56:23 +0200 )edit
1

answered 2019-05-31 00:16:38 +0200

Chirend gravatar image

Wow thanks. This workaroud saved my XA2. Since everyone around me uses Whatsapp. This made me abel to use it again on Saifish. I don't know why the Android 8 Beta is so bitchy, Whatsapp worked just fine on my Jolla 1 with Android 4 support.

edit flag offensive delete publish link more

Comments

Good to know that we can help someone :)

Stanislav1988 ( 2019-05-31 06:27:35 +0200 )edit
1

answered 2019-05-31 20:56:01 +0200

teemu gravatar image

updated 2019-05-31 20:57:01 +0200

Not an answer but a question on specific scenario:

As an example, I flashed my phone back in the day with v16 vendor image of XA2.

I have since updated Sailfish OS to 3.0.3.10 and installed opengapps.

If I now want to upgrade my vendor binaries to v17B using fastboot, can I just do it by these instructions, or will my patched system.img be effected by the process?

https://jolla.zendesk.com/hc/en-us/articles/360019346354?mobile_site=true

Am I right that these two img files have nothing to do with each other, despite "Android8.1" being there in the name of the vendor image?

edit flag offensive delete publish link more

Comments

1

Yes, these are two completely different things. The vendor binaries are about the Android HAL on which Sailfish is running, while this question is about the Android compatibility layer that runs on top of Sailfish. There was a detailed explanation by @DrYak somewhere on TJC about SailfishOS and Android.

Giacomo Di Giacomo ( 2019-05-31 21:05:54 +0200 )edit

Ah, that one. It is a magnificent post.

https://together.jolla.com/question/203644/xperiax-aosp/?sort=votes&page=1#203664

teemu ( 2019-05-31 21:38:57 +0200 )edit
1

answered 2019-06-11 16:41:13 +0200

callybrex gravatar image

Worked like a Charm, but getting now evertime the Notification about updating Play Services. The Update isnt possible because the only Button there is "Deactivate".

edit flag offensive delete publish link more
1

answered 2019-06-23 14:49:22 +0200

groeable gravatar image

It's not wotking for me. I follow the instructions and Android setup screen didn't appear. I'm using sony xperia xa2 with the latest sfos. Any advice?

edit flag offensive delete publish link more

Comments

You have the v17b vendor binary?

I don't know if it may be the reason, but my recent factory reset and attempt with XA2, 3.0.3.10 and v17b was much more messy than my previous one with 3.0.3.9 (I believe) and v16. The bug with unresponsive Android apps when opened by the system made the Android initialization a grievous affair.

If you got v17b, I would change it to v16 and try again.

But, before that, do you have Android apps installed? Go to Settings - Apps - [Android app] - Open Android Settings, and press the Android's back button to get to the main Andtoid Settings. Can you do that? If a window opens up but is unresponsive, try to minimize it (to the cover view) and again maximize it.

Also, did Play Store install and appear to you?

teemu ( 2019-06-23 15:00:17 +0200 )edit

I can go back to android settings. Nothing happend after overwrite system.img and start android support so no play store, no google services, nothing. And I have 3.0.3.10

groeable ( 2019-06-23 15:08:34 +0200 )edit
0

answered 2019-05-17 09:18:06 +0200

Stanislav1988 gravatar image

SMALL UPDATE

Google Play Store works, but you can only download and upgrade your apps using mobile network on Wi-Fi it always get "pending" message.

edit flag offensive delete publish link more

Comments

isnt that a.standard xa2 problem at the.moment ?

pawel ( 2019-05-17 10:19:56 +0200 )edit

hmmm on release note, was point that apps can use wi-fi and mobile network.

Stanislav1988 ( 2019-05-17 10:38:56 +0200 )edit

This is nothing new, it has been this way for months if not years. Google Play services versions issued in the latest times won't download apps from non-Google-registered devices. Actually, I don't understand how you got to download apps with mobile network. It should not work.

Giacomo Di Giacomo ( 2019-05-17 11:26:05 +0200 )edit

@Giacomo Di Giacomo I know, but on mobile network, download apps from Store working, first when I launched Facebook it asking me "if I want download messanger" so I click download and it take me to the Google Play Store and download messanger.

https://imgur.com/a/yfCiDjQ here is a link to screenshoot

Stanislav1988 ( 2019-05-17 11:50:47 +0200 )edit

@Stanislav, can you use now Google music?

carmeloferso ( 2019-05-17 21:06:42 +0200 )edit
0

answered 2019-05-29 12:13:15 +0200

Stanislav1988 gravatar image

updated 2019-05-29 14:14:37 +0200

On update 3.0.3.10 SailfishOS have new version of their squashfs-tools and command squash in this script file will not work

Ok, I search in Google (thanks uncle you are not bad as they say XD ) and we have new version of squash-tools and libzma required to install squash-tools

links: -libzma -squash-tools

We must copy this two rpm files (becarefull you must choose right .rpm file for armv7hl) and install with command pkcon install-local .... (where .... is a name of rpm file)

rest of this tutorial is same.

edit flag offensive delete publish link more

Comments

Does the --nodeps in the original installation of squashfs-tools (in this tutorial) mess up anything with the Sailfish OS package managing, if the OS update is now replacing it with new version?

teemu ( 2019-05-29 13:51:09 +0200 )edit

@teemu I think yes it replace current version of squashfs-tool because when I tried run command to use script, I had a error (system files use lz4 commpresion that it`s not available in this tools and I had a list of available compression like lzma, gzip etc.) so I searched some information in Google and tried install new version of this tool used in tutorial.

Stanislav1988 ( 2019-05-29 14:11:57 +0200 )edit

Running again the last two rpm commands above does not work?

Giacomo Di Giacomo ( 2019-05-29 16:04:27 +0200 )edit

@Giacomo Di Giacomo Did you use this command as root? And dont use commands from tutorial, you must install this two files with pkcon **install-local** then use command in directory where you have .sh script file and opengapps file. But I discovered issue when I remove android directory before use tutorial, all apps icons still existing in system but after click application dont launch ad I must reinstall all apps

Stanislav1988 ( 2019-05-29 16:35:45 +0200 )edit

I haven't tested it yet, but all the procedure must be executed as root, it's stated above.

Giacomo Di Giacomo ( 2019-05-29 16:40:40 +0200 )edit
0

answered 2019-07-20 11:27:34 +0200

teemu gravatar image

Notes on Early Access update to 3.1.0.11:

The modified /opt/alien/system.img gets replaced in the update, causing the Play Services dependent apps like Play Store and Easy Park to not start after the update.

Re-running the revised script by @Artur fixes the issues, and those apps start working again.

edit flag offensive delete publish link more

Comments

This is specified in the howto above.

Giacomo Di Giacomo ( 2019-07-20 20:34:37 +0200 )edit

Yes. I posted only to confirm that I didn't experience any surprises there; that there indeed is an update to system.img in 3.1 (hardly a surprise, yes), and that the Google-dependent apps that stop working after the OS update will get revived by just re-patching the system-updated system.img.

Just in case someone might've been wary of updating to 3.1, or didn't yet get the update because of not being opted for Early Access.

teemu ( 2019-07-21 00:39:26 +0200 )edit

I did have serious problems updating from scratch though (after installing MicroG and trying opengapps again). Maybe I will post about them later.

Giacomo Di Giacomo ( 2019-07-21 02:33:38 +0200 )edit
0

answered 2019-07-21 17:27:24 +0200

Giacomo Di Giacomo gravatar image

updated 2019-07-22 05:04:18 +0200

Installing on a clean SFOS 3.1 system does not complete configuration on first startup of Android support. If I use the former procedure with files downloaded by hand, wifi and mobile data are not recognised. If I use the integrated script. the configuration goes on and I can enter my Google account but stays forever on the final screen, and occasionally restarts from the beginning, but never exits.

edit flag offensive delete publish link more

Comments

1

Select "skip" when the wizard asks to select network, and don't log in with your Google account during the setup.

(Then try logging in to Google from settings, after finishing the setup, if you really want it.)

Artur ( 2019-07-21 17:57:58 +0200 )edit

Hi Arthur. I try your tutorial and 100% installed, but always when in configuration frist startup of android loop to initial sesion configuration. Else cancel session to WIFI and SIM card and the last option says: Analisy more apps and down says: Finish for moment and loop same page... Else I close this page and ill open configuration Android to login my account Google but says now Verification Data... and no move nothing. Please can help me?

Rafaelvlmendes ( 2019-07-26 03:52:12 +0200 )edit

@RafaeMmendes It's the exact same thing that happens to me on 3.1.

Giacomo Di Giacomo ( 2019-07-26 09:50:18 +0200 )edit

I try with the options rm -rf /home/.android/* and now 100% ok. But i have problem with Whatsapp: The diretory Android_storage no want restore my backup and no want download photos and videos. Touch sound too no want disable.. Have You a solution?

Rafaelvlmendes ( 2019-07-26 10:22:05 +0200 )edit

@Rafaelvlmendes I can download WhatsApp photos, and I don't have a backup to test with. Check if WhatsApp has storage permissions. (Sailfish Settings -> Applications -> WhatsApp -> Open Android settings)

Artur ( 2019-07-28 15:10:44 +0200 )edit
Login/Signup to Answer

Question tools

Follow
22 followers

Stats

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

Seen: 9,973 times

Last updated: Dec 21 '19