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

[How-to] Install MicroG on XA2 (Android 8.1)

asked 2019-02-24 20:34:12 +0200

this post is marked as community wiki

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

updated 2019-07-22 04:39:26 +0200

DrYak gravatar image

update 2017-07-21 : This is for Sailfish OS up to 3.0.3 Hossa. Starting from 3.1.0 Seitseminen, the Signature Spoofing is built-in, there's no need for patching, only to activate it in Settings, and grant the Signature Spoofing capability in Android Settings. Modifying system.img is still required for mapsv1 API, but it's a bit simpler.


Edit: Check the answer by yeoldegrove for an automated script, thank you to yeoldegrove!

Hopefully this is not a duplicate.

I just managed to get the signature spoofing and MicroG working on XA2 (3.0.1.14) with the new Android support so I thought to write a small how-to if others are interested.

Note that you should do this before installing Android apps. Many apps will crash if you install MicroG after them, but you can reinstall the apps and they should start working. Also you probably need to do this everytime there is an update for the Android Support and the system.img is changed.

What's needed:

-squashfs-tools (available for both Windows and Linux, I used the Linux version)

-vdexExtractor (https://github.com/anestisb/vdexExtractor AFAIK only works on Linux)

-SmaliPatcher (https://forum.xda-developers.com/apps/magisk/module-smali-patcher-0-7-t3680053 AFAIK only works on Windows)

Steps:

Get the file /opt/alien/system.img from your phone and copy it to your PC (make a backup too)

Use squashfs-tools to unpack the .img file

unsquashfs /path/to/image/system.img

Get the following files and copy them to another folder

unpacked_image_path/system/framework/oat/arm/services.vdex

unpacked_image_path/system/framework/services.jar

Deodex the services.vdex with vdexExtractor

/path/to/vdexExtractor/bin/vdexExtractor -i path/to/services.vdex --ignore-crc-error

Now you should have a file called services_classes.dex, you need to rename it to classes.dex and pack it into the services.jar file

zip -j path/to/services.jar classes*.dex

Now you need to use SmaliPatcher to inject the signature spoof patch to the services.jar (which now includes the classes.dex file). So switch to Windows (unless you can find a Linux version of smalipatcher) and use the graphical UI to patch services.jar. I chose the default settings which includes mock location patch and the signature spoof patch. You probably only need the signature spoof patch.

SmaliPatcher creates a .zip file which includes a /system folder. Copy this system folder over your unpacked_image_path/system to replace the original files with the patched files.

Now use squashfs-tools again to pack the files to system.img

mksquashfs unpacked_image_path/ system.img -comp lz4 -Xhc -noappend -no-exports -no-duplicates -no-fragments

Copy the new system.img to your phone. Make sure Android Support is not running.

As devel-su: cp /path/to/image/system.img /opt/alien/system.img

Press y to confirm overwrite (make sure you have backup of the original system.img)

(Not sure if necessary but I set the permissions of system.img to match the original by:)

As devel-su: chmod u=rw,g=r,o=rw /opt/alien/system.img

Start the Android Support. Install MicroG from F-droid repo. You should see signature spoofing enabled and MicroG working.

Thanks to people on thread https://together.jolla.com/question/198500/xperia-xa2-sailfish-x-dont-have-systempriv-app-directory/ for getting the squashfs parameters right, thanks to authors of vdexExtractor, SmaliPatcher and of course the MicroG team. Also thanks to the author(s) of NanoDroid for creating a tutorial for deodexing.

Hopefully I got everything right. Please share any improvements you might have in mind for this tutorial. Happy patching =)

edit retag flag offensive close delete

Comments

Wouldn't the video by leszek be easier? I'm asking because I cannot try since I don't have an XA2.

Giacomo Di Giacomo ( 2019-02-24 20:40:24 +0200 )edit

I think that video tutorial is missing the signature spoof patch which is the hardest part of the process. I'm not exactly sure if MicroG works 100% without the patch, would be nice if someone can test if it is necessary or not.

synthent ( 2019-02-24 20:45:30 +0200 )edit

The Video is without Singature Spoofing, which is really the hardest thing here. Some thinks work without it, but the most need Spoofing ;) So thank you for this tutorial!! I'll try it ;)

jayki ( 2019-02-24 21:00:01 +0200 )edit
1

This is a PITA. I guess the system.img file is the same for all phones. There should not be copyright issues if some kind soul made available the patched file for other users to download, since it's all freely available stuff.

Giacomo Di Giacomo ( 2019-02-24 21:12:43 +0200 )edit
6

Give a man a patched image and he will enjoy MicroG until the next Alien Dalvik update. Teach a man to patch the image himself and he will enjoy MicroG until it goes unmaintained :)

synthent ( 2019-02-24 21:24:09 +0200 )edit

9 Answers

Sort by » oldest newest most voted
11

answered 2019-02-25 00:52:59 +0200

yeoldegrove gravatar image

If you're on linux you might want to check out https://github.com/yeoldegrove/sailfish-signature-spoofing This is what I use for setting up the spoofing. It is fully automated once you set up the docker container.

edit flag offensive delete publish link more

Comments

but docker is for windows or mac os x so how it use on linux?

Stanislav1988 ( 2019-02-25 12:02:36 +0200 )edit

haven't tested building/running it on windows, that's what I meant

yeoldegrove ( 2019-02-25 13:27:41 +0200 )edit
1

@Stanislav1988 Docker is for Linux, Mac, Windows Used this on Linux. Works perfectly

Crypto ( 2019-02-25 23:56:17 +0200 )edit

This method working, can confirm. Thanks again to @yeoldegrove!

ExPLIT ( 2019-02-28 02:01:36 +0200 )edit
1

Thank you @yeoldegrove for great script that made this much easier!

I had to modify run.sh to make it work:

Replace line that has

/haystack/patch-fileset /haystack/patches/sigspoof-hook-7.0-7.1 ${API_VERSION} /sailfish/framework /hook

With:

/haystack/patch-fileset /haystack/patches/sigspoof-hook-7.0-9.0 ${API_VERSION} /sailfish/framework /hook

Also on linux, I had to add my user to docker group else it wouldn't work. Running the docker command using sudo was not sufficient.

But after these steps signature spoofing utility reported success. Unfortunately it did not help with most of the applications I wanted to run. But at least one application started working with microg installed that did not before.

ajalkane ( 2019-03-02 19:36:45 +0200 )edit
5

answered 2019-04-24 19:23:07 +0200

synthent gravatar image

Something I noticed while updating to 3.0.3.8: the update didn't go all the way in when updating the official way from the settings app. After rebooting and trying updating from the terminal the process stopped at the alien dalvik package and I got an error message stating that the /opt partition needs 80mb of free space. After removing the backup of system.img from /opt/alien the update went through.

It might be better to store the backup somewhere else than /opt.

edit flag offensive delete publish link more

Comments

How is that related to this MicroG howto?

Pohli ( 2019-04-24 21:24:13 +0200 )edit
5

Like by fixing a problem that arises from following the howto?

Smar ( 2019-04-24 21:25:59 +0200 )edit
1

There is no other space than /opt on the phone itself...

yeoldegrove ( 2019-04-25 18:44:39 +0200 )edit
1

@yeoldegrove Maybe I misunderstood your post but in case I didn't:

[root@Sailfish nemo]# df -h
Filesystem            Size  Used Avail Use% Mounted on
...
/dev/mmcblk0p71       821M  584M  214M  74% /opt
....
synthent ( 2019-04-25 21:32:02 +0200 )edit
2

Basically :

/opt has only space for two copies of system.img: the current and the one getting upgraded from the rpm.

@yeoldegrove 's docker would require space for tree copies: the currently patched, the pre-patching backup, and the one getting upgraded.

There's not enough space for that on the partititon. You need to either delete the backup or move it to the SD card.

DrYak ( 2019-04-26 12:00:37 +0200 )edit
3

answered 2019-05-09 16:13:13 +0200

DrYak gravatar image

updated 2019-05-13 20:54:10 +0200

update: 2019-05-12 - I got some time to quickly test this week-end:

  • Putting the APK in priv-app correctly marks the service as priviledge, but UnifiedNLP still doesn't register
  • The Haystack adaptation of the patch mentionned by bomo in the comment, does apply successfully without any error, BUT still doesn't register UnifiedNLP.

I'm out of ideas


GPS problems:

I'm trying to investigate why some Android apps can't manage to get a position lock, despite MicroG being installed.

I've found this piece of information:

Apparently, above Android 7.0 Nougat (such as the AOSP 8.1 Oreo on our XA2s), the Location service need to be priviledged to work. (Hence perhaps the "UnifiedNLP registered" self-check failing ?)

  • When I have some free time (week-end ?), I might try to test if it works when deployed into /system/priv-app on the system.img SquashFS image
  • They provide a patch to enable non-priv UnifiedNLP on versions 7.0+ but that is way beyond my competencies in patching Android. Even if the above test work, somebody more competent would need to work out how to patch that with haysack.
edit flag offensive delete publish link more

Comments

Same issue here... Would be happy to receive a solution.

xneo ( 2019-05-09 16:37:51 +0200 )edit
1

Maybe interesting in this context as this patch is used by most guys I guess: https://github.com/Lanchon/haystack/issues/3

bomo ( 2019-05-10 00:49:11 +0200 )edit

thanks @bomo, looks like for the guy on that issue this fixes the exact same problem as we're having. he even showed how he wrote the patch.

DrYak ( 2019-05-10 10:55:07 +0200 )edit
2

answered 2019-02-25 15:26:28 +0200

Stanislav1988 gravatar image

updated 2019-02-25 17:05:36 +0200

Ok finally I install microG services correctly, I can log into my google account using google music but after that I have strange issue, it require to let add this account after that it back to first page where I must click add account, bt this time it say account already exist O_O ehhh, still no step further to have google music, but if you want help (if you know what I mean) ask me on tellegram @Stanisław

edit flag offensive delete publish link more

Comments

same issue here. i was only able to add an account once. but MicroG doesn't see added accounts and always asks to add a new one.

Crypto ( 2019-02-28 11:38:48 +0200 )edit
2

answered 2019-02-28 18:44:43 +0200

Stanislav1988 gravatar image

I think about adpt this project patcher maybe can someone make simillar app

edit flag offensive delete publish link more
1

answered 2019-02-26 20:53:55 +0200

babo gravatar image

Thank you so much for this HowTo, however it took me a very long time trying to figure things out, and I guess for someone with a little/less than average knowledge with Linux might need a more detailed one instead. So it would be very much appreciated if some one provides deeper instructions.

For me, that didn't work. I don't know if I missed anything. After doing all the steps mentioned and replacing the system.img (last step), Android Support got greyed out and the file was smaller than the original /opt/alien one, just like @glalli reported.This is NOT related to android apps being installed though, since I have tried removing all apps together with Android Support (several times) and reinstalling it and replacing the .img file and still didn't work. As for the second time I tried from scratch, SmaliPatcher kept saying that the image is not deodexed even though it was. This could be from my side though, no idea.

Any help is much appreciated.

edit flag offensive delete publish link more

Comments

Did you tried https://github.com/yeoldegrove/sailfish-signature-spoofing or the one that was from the original post?

Hoxifi ( 2019-02-26 22:22:03 +0200 )edit
2

the one from the original post seemed a bit complicated i dont know ,however I might give this one a try...... but the problem is, that whoever writing guides/instructions assumes that all people are well informed and experienced about this stuff,and it takes a lot of time to figure things out,and by the time that you actually have a grip on things something fails where you would be already at a point exhausted and never giving a damn about it

babo ( 2019-02-27 01:26:26 +0200 )edit
1

answered 2019-05-06 10:57:44 +0200

Stanislav1988 gravatar image

Can someone tell me if I upgrade to newest version of SFOS . I will must do everything once again?

edit flag offensive delete publish link more

Comments

yes, and do not forget to remove the backup of the system.img file before the upgrade to avoid a failing upgrade

balta ( 2019-05-08 17:04:32 +0200 )edit
0

answered 2019-05-13 23:29:04 +0200

glalli gravatar image

By following the docker based procedure I am able to get the apps relying on Google Services to work. Sadly the location/maps part is not working. GPS is working fine when using native SFOS apps like Pure Maps. But when I try to open apps like car2go or uber I am not able to get the location services to work. They are enabled in android settings. Installing Google Maps did not help. Anyone any clue on how to find a way forward?

Thanks

G

edit flag offensive delete publish link more

Comments

@glalli Upon my XA2 under Location > Custom with GPS positioning, Offline & Online position lock from Mozilla enabled. Under microG have Apple UnifiedNip Backend, Déjà Vu, Local GSM location & UnifiedNip (no GAPPS) Location provider middleware installed. Had just about given up until GPS suddenly showed 9/35 Satellites in use/view after leaving phone outside for about 20 minutes. Whether installation of Google Maps triggered something however I do not know. Have a look at this resource: link text

scoobyman ( 2019-05-14 09:18:19 +0200 )edit
0

answered 2019-09-30 14:07:40 +0200

Raymaen gravatar image

Would it be possible to offer a micgrog app directly from the Jolla Store for not techsavy people like me? Or would there be issues with licensing?

edit flag offensive delete publish link more

Comments

1

Note that this guide is outdated. As of 3.1.9 Seitseminen, you can indeed just straigh fetch microG from an app store.

Except you use F-Droid app store instead of the official Jolla app store.

microG is open source (Apache lincense). There aren't any licensing limitations that would prevent you Jolla form featuring it in the official store.

(Note that F-Droid is interesting as they don't merely host binary APK packages provided by the app developers. Instead the developers provide only the source code, and F-Droid compiles it).

DrYak ( 2019-09-30 20:04:07 +0200 )edit

I tried it out, but after i installed those aps and restarted, i wasnt able to make or receive calls annymore... very strange... so i kickt them again and after restart my phon worked again... well thats what i mean, an out of the box solution for people like me ;-)

Raymaen ( 2019-10-02 09:02:02 +0200 )edit

There is a completely unrelated problem on XA2 phone (might happen also on some X) that cause the phone not being able to make calls upon reboot. It has nothing to do with installing microG, and is entirely linked to reboots.

As mentioned elsewhere in this forum, you can restore the call function by :

  • on a dual sim: turn slot 2 on, tirm slot 1 off then on, turn slot 2 back to off.
  • on all: turn airplane mode on then off
  • if you have "sailfish utilities", while the airplane mode is on, restart networking services.
  • shutting the phone completely off, remove the sim tray, wait a bit, reassemble and restart.
DrYak ( 2019-10-03 00:19:01 +0200 )edit

How about update to 3.2 ? Any special steps to take to make sure all is running ok after update.

jpjolla ( 2019-10-30 21:32:36 +0200 )edit
Login/Signup to Answer

Question tools

Follow
25 followers

Stats

Asked: 2019-02-24 20:34:12 +0200

Seen: 9,145 times

Last updated: Sep 30 '19