Installing LineageOS for MicroG on the Google Pixel 3a

By: Owen T. Heisler
Updated: 2022-05-23
Published: 2021-06-09

The goal

  • Mostly open source operating system

  • For privacy and security, no Google account/login is required

  • Apps from the Google Play Store are available for use

  • System root available for any apps that require it (such as ad blockers)

  • Uses the privacy-respecting microG substitute for the Google Services Framework (required by many apps on the Play Store)

  • Software updates beyond Google’s end-of-life (May 2022—see When you’ll get Android updates on Google Support)

The phone

Obviously this page targets the Google Pixel 3a, but of course there are a variety of variants falling under this designation.

  • Model G020G, the “North America” model

  • The phone is bootloader unlockable. This is an absolute requirement: locked bootloaders prevent the installation of custom software on a phone. Generally, Pixel devices purchased from Google are bootloader unlockable whereas devices purchased from carriers are not, but this is not universally true.

  • The phone is SIM unlocked—not necessary for installing LineageOS, but I recommend only purchasing SIM unlocked phones so the device’s network compatibility is not artificially limited.

For more information about the Pixel 3a, see the Pixel 3a Wikipedia page.

Computer requirements

A computer with the Android adb and fastboot utilities is required. On Debian 11 Bullseye, these can be installed by running apt install adb fastboot as root.

A USB port and a USB-C cable are also necessary.

Also download the LineageOS for microG files before starting—see Install LineageOS for microG, below.

Unlock the bootloader

To unlock the bootloader:

  1. Navigate to Settings > About phone and tap Build number multiple times until developer options are enabled.

  2. Navigate to Settings > Developer options and enable both OEM unlocking and USB debugging.

  3. Connect the phone to your computer and run adb reboot bootloader. The phone may ask whether to Allow USB debugging?—tap Allow. Run the command again if it times out while requesting permission. The phone should now be in Fastboot Mode.

  4. Check that the device is visible in fastboot mode by running fastboot devices. The device should be listed. Then run fastboot flashing unlock to unlock the bootloader. Use the volume keys on the phone to select Unlock the bootloader and then press the power button to confirm.

  5. Once the phone has finished resetting, press the power button (Start) to boot the phone again.

Update the stock firmware

Before beginning the process of setting up LineageOS for microG, the stock firmware should be updated. This is necessary because LineageOS cannot maintain and distribute all of the phone’s firmware, such as the modem firmware, but LineageOS does expect that firmware to be current (as published by Google—see Google’s Factory Images for Nexus and Pixel Devices).

To update the stock firmware, navigate on the phone to Settings > System > Advanced > System update. Repeatedly check for, install, and apply updates until there are no more updates available.

Install LineageOS for microG

In addition to the steps below, you can consult the LineageOS for microG Installation instructions as well as the Install LineageOS on sargo page on the LineageOS Wiki.

  1. Download the recovery image and installation package. See the LineageOS for microG sargo downloads listing. You need the latest *.zip and *.img files. I used these:

    $ sha256sum *
    ccaac2391eeb4fddb7c045b18c814b9a9c50135e70e9c9fa9073b7f3f0d84d47  lineage-18.1-20210411-microG-sargo-recovery.img
    005f6eb4549e782ed6e1a47f529bc4eab19098fb77c9abdd9803a589ce3d2294  lineage-18.1-20210411-microG-sargo.zip
  2. Enable USB debugging again as described in Unlock the bootloader (steps 1 and 2).

  3. Connect the phone to your computer and run adb reboot bootloader. Again the phone may ask whether to Allow USB debugging?—tap Allow. Run the command again if it times out while requesting permission. The phone should now be in Fastboot Mode.

  4. Flash Lineage Recovery on the phone by running fastboot flash boot lineage-18.1-20210411-microG-sargo-recovery.img (for example).

  5. Use the volume keys to select Recovery Mode and press the power button to confirm. The phone should boot into Lineage Recovery with a menu.

  6. Tap Factory reset and Format data/factory reset and finally confirm by tapping Format data. You can ignore any can't send spi message errors in the output. Once the format is complete, return to the main menu by tapping the back arrow.

  7. “Sideload” the installation package by tapping Apply update and Apply from ADB. The phone will wait to receive the package. On the computer, run adb sideload lineage-18.1-20210411-microG-sargo.zip (for example) to send the file to the phone. When this is finished, go back to the main menu, navigate to Advanced, and tap Reboot to recovery.

Install Magisk

Magisk can be installed by renaming the app APK and sideloading via Recovery.

  1. Download the Magisk v24.1 (or later) APK to the computer. The file is available on the Magisk Releases page on GitHub.

  2. On the computer, change the Magisk APK file extension to .zip (for example, mv Magisk-v24.1.apk Magisk-v24.1.zip).

  3. From recovery, tap Apply update and Apply from ADB.

  4. Sideload the Magisk ZIP file:

    $ adb sideload Magisk-v24.1.zip
  5. When asked about failing signature verification, accept it by tapping Yes.

  6. Reboot the phone.

  7. Navigate to System > Advanced > Developer options and disable USB debugging.

  8. Open the Magisk app, open the settings (the gear icon at the top right), and tap Systemless hosts. This will add a Magisk module that allows modification of the hosts file (commonly used for ad blocking).

In this case, we are using Magisk to provide superuser/root access for apps that require it. Magisk will prompt you when an app requests root access. Apps with permission are listed in the Magisk app, on the Superuser page (look for the button at the bottom).

Magisk can also install modules to modify system partitions during the boot process. Modules are managed on the Modules page of the Magisk app. There are no modules that need to be installed for the purposes of this document.

System configuration

  1. Open the F-Droid app, navigate to Settings > Repositories, and enable the Guardian Project repository.

  2. In Settings, navigate to System > Advanced > Developer options. Disable USB debugging; you can enable it again later if necessary. Enable Local terminal for local shell access—look for Terminal in the app list and type su to get root access there if necessary.

  3. In Settings, navigate to System > Advanced > microG Settings > Location modules and enable both. If asked for permission, set it to Allow all the time by following the instructions given.

  4. Some GSF-dependent apps use Google’s Cloud Messaging (GCM) service to register for “push” notifications. Without cloud messaging, an app may that depends on it not receive messages promptly. Cloud messaging can be enabled in microG Settings: first enable Google device registration and then enable Cloud Messaging. If you have an app that you think uses cloud messaging but microG Cloud Messaging status shows On - 0 registered Apps, then try the following.

    1. Disable Cloud Messaging and then disable Google device registration. Reboot the phone.

    2. Enable Google device registration and reboot the phone.

    3. Enable Cloud Messaging and reboot the phone.

    See orestarod’s post on Reddit for some other things to try if that does not work.

Other suggestions

  • Adaway, available on F-Droid, can be set up to block ads system-wide. Choose Root based ad blocking.

  • The Aurora Store app, available on F-Droid, allows you to browse and install apps from the Google Play Store. Choose the Root installer method. You do not need to have/use a Google account; just select the Anonymous login. Because you do not want Aurora Store to replace microG with the standard Google Play services app from the Play Store, be sure to blacklist the com.google.android.gms app: tap Updates tab at the bottom, long tap the Google Play services app, and tap Add to Blacklist (in the Blacklist Manager, the app will be labeled as microG Services Core). Aurora Store will indicate when an app “requires GSF” (the Google Services Framework); these services are being provided by microG instead.

  • The Signal app, available on the Play Store via Aurora Store, provides end-to-end encrypted messaging and calling on Android and iOS. Signal Desktop is also available for Linux, macOS, and Windows. Note that Signal uses your mobile phone number as your ID, so unfortunately a phone and phone number are required. (Perhaps at some point Jami will be able to replace Signal with a more robust decentralized messaging system.) If you have cloud messaging enabled but Signal has not registered, trigger a new attempt: in Signal, navigate to Settings > Privacy > Advanced, and disable and enable Signal messages and calls (you will have to receive an SMS message to re-register, so make sure you are able to receive an SMS message when you do this).

  • Battery life (referring to battery aging, measured in months/years, not runtime measured in hours) can be significantly improved by using charge thresholds. Consider installing AccA, available on F-Droid. This is an installer and interface for the Advanced Charging Controller (ACC). Make sure Magisk is active before running AccA; it will require superuser privileges. AccA can automatically install ACC for you, likely as a Magisk module. For more information about improving battery life, see Battery University’s BU-808: How to Prolong Lithium-based Batteries.

Updating

System updates provided by the Lineage for microG project can be installed via the regular Lineage Updater mechanism at Settings > System > Updater. However, before rebooting, install Magisk again. This time, select the Install to Inactive Slot (After OTA) method. Reboot after the installation is finished. Magisk and any installed modules should persist if everything works correctly. If Magisk does fail to persist across the system update, reinstall it by enabling USB debugging, running adb reboot recovery, and following the instructions in the Install Magisk section.

Note that major upgrades may require manual action; in this case, follow the manual upgrade steps outlined in Upgrade LineageOS on sargo, using the microG files instead of standard LineageOS. Before rebooting (or after, it doesn’t matter), sideload Magisk again as described in the Install Magisk section.

Credits

  • Thanks to the microG Project developers who also publish builds of LineageOS for microG

  • Thanks to the LineageOS developers and maintainers

  • Thanks to orestarod for his post on Reddit

Changes

  • 2022-05-23: Added a step in Install Magisk for adding the Magisk hosts file module

  • 2022-02-12: Updated the AccA/ACC entry in Other suggestions (AccA can do the ACC installation itself)

  • 2022-02-12: Updated various details in the Install Magisk section for Magisk v24.1

  • 2022-02-12: Improved the Updating section by changing the Magisk installation method and adding details about major upgrades

  • 2021-12-13: Simplified Magisk installation and updating by using the sideload installation method

  • 2021-10-26: Extended the Updating section with explicit steps

  • 2021-09-05: Added the Updating section

  • 2021-06-22: Simplified steps for setting up cloud messaging

  • 2021-06-22: Added Signal instructions for re-registering cloud messaging

  • 2021-06-22: Added note about blacklisting the microG app in the Aurora Store

  • 2021-06-21: Changed order to unlock the bootloader first, then update stock firmware

  • 2021-06-10: Added more details about setting up cloud messaging