[Miscellaneous Android Development] PsychicPterodactyl:
This guide can actually apply to any device and ROM

What is microG?

microG is a free reimplementation of GApps, which allows for more privacy and better battery life.

How to get microG on my ROM?

There are three steps:

Get rid of any GApps you already have installed (I don't mean Google Play Music etc, I mean Google Play Services, Google Play Store etc)

Enable signature spoofing

Install microG components & enable them

How to enable signature spoofing

The main component that microG aims at replacing is Google Play Services. In order to do this, it must be able to fake that it's Google Play Services, and it needs signature spoofing to do this.

There are three main ways to enable signature spoofing:

Some custom ROMs already have this as an option, such as crDroid. For a list of such ROMs and how to enable the feature, go here.

There is also an xposed module available here that enables signature spoofing

You can patch the ROM to allow signature spoofing. Either by installing someone else's patch, such as my patch for Asfand's RR 5.8.5, which you can download from here and enable at the bottom of the developer settings, or patch the files yourself using Haystack. You will need a Linux system to patch it yourself. The procedure itself is not complex, it involves downloading a set of scripts, taking 5 or so files out of your ROM, running 3 scripts on them them putting them back into the ROM. By the way: you do not need to operate like in the tutorial here, you can just take the files out of the ROM installation script, patch them, them put them in place of the files in the patch zip I created that I linked above.

How to install microG components

After having enabled signature spoofing, you want to install the various microG components. The classical way is to download the various files and manually place them into the ROM, but you can also use ale5000's unofficial installer and simply flash the zips he provides from your recovery. If you want Google Sync to also work you can flash the Google Sync Add-on he provides, or otherwise use something like DAVDroid for calendar and contact synchronisation.

Once you have installed microG, boot up your phone and open the microG settings app. Open the self-check section. Our goal is to have everything in this section ticked. If all went well, you should have signature spoofing and almost everything checked.

You will need to disable battery optimisations for GSF by tapping on the relevant section, so that it may maintain a stable connection (this is the same as with Google Play Services, just that it uses much less battery as it is not tracking your every move).

You will also need to enable UnifiedNLP in the UnifiedNLP settings (one menu back), configuring both a location and address lookup backend.

If you used the unofficial zip installer you should have Mozilla Location Service and Nominatim available. More information on the available backends can be found here.

Once you have enabled the backends you will also want to enable your phone's location services on High Accuracy or Battery Saving modes, and reboot.

You can now check if everything is ticked in the self-check section of microG settings (you might need to enable your WiFi or data connection and find your current location using some app in order for it to have your last known location checked).

You can the proceed to enable Google device registration to get the Play Store to work correctly and Google Cloud Messaging to get notifications to work correctly. Some apps may also force you to enable Google SafetyNet or they refuse to work.

You will need to reboot now to get everything we enabled to work properly

Extra information:

Currently Google Play Games is not compatible with microG.

Google Hangouts is only compatible through the use of a patched apk

To get Gmail working correctly you need to give it permission to access contacts

For extra privacy you might want to disable all permissions for Google Play Store except for storage

And that's it! You and your battery are now a little bit freer from Google's shackles :highfive: