[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 a wiki. Anyone with karma >75 is welcome to improve it.
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".
Install
lzip
and a version ofsquashfs-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
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.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 commandchmod 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
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).
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
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@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 )editStrange 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@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