[Google Pixel 4a Guides, News, & Discussion] nor-ric:
Hello,

I'm posting this guide for those (like me) who can't do without TWRP on their device.

I'm providing only a step-by-step explanation. Credits to @nikamura for his kernel and TWRP: https://xdaforums.com/t/twrp-3-4-0-0-for-sunfish-testing.4179101/

Credits to @Zackptg5 for his guide, from which I've started: https://xdaforums.com/t/guide-unlock-root-safetynet-for-pixel-4a.4153773/

Credits to @topjohnwu for Magisk: https://github.com/topjohnwu/Magisk

DISCLAIMER: I don't take any responsibility if your phone explodes or anything... The guide is provided as is.

FIRST STEP: UNLOCKING THE BOOTLOADER

Download USB drivers for your phone here: https://androidfilehost.com/?fid=8889791610682922010

Download SDK Platform-Tools for Windows here: https://developer.android.com/studio/releases/platform-tools

Extract the SDK Platform-Tools to a directory of your choice.

Open your command prompt, change directory to where you extracted the Platform-Tools and type "fastboot". Depending on your Windows setup (I'm a linux guy, so I've used an ancient win8.1 installation in a VM...) you might receive a message of a missing dll (api-ms-win-crt-convert-l1-1-0.dll): if so, download and install the Universal C Runtime from https://support.microsoft.com/en-us...-windows-c0514201-7fe6-95a3-b0a5-287930f3560c

If you try the "fastboot" command once more, it should now work.

On your phone go to system settings -> About phone -> tap on 'Build number' several times until Developer Options is enabled.

Back out into settings and go to System -> Advanced -> Developer Options -> Enable 'OEM Unlocking'.

Switch off the phone.

Boot into fastboot by holding Vol Down + Power.

Plug the phone into a usb port of your pc.

In your command prompt type "fastboot devices". If there is no output, it means you have to install the USB driver. So, open "Device Manager" on your pc, right click on your Pixel 4A (should be on top of the list with a yellow exlamation mark) and update the driver choosing the USB drivers you previously downloaded. In Device Manger you should now read "Android Bootloader Interface", with no exlamation mark.

Now back to the command prompt, "fastboot devices" should now output a string with "fastboot" written next to it.

Now type 'fastboot flashing unlock' -> Follow prompt on the device to unlock the bootloader (note that this will FACTORY RESET the device).

The bootloader is now unlocked! You can now safely reboot (or it reboots on its own, I don't actually remember).

Note that after you unlock the bootloader you will see a reminder for a few seconds every time you reboot, reminding you that the phone is unlocked. That's normal and we have to live with that, as far as I know.

SECOND

STEP: USING THE FACTORY IMAGE TO DOWNGRADE TO ANDROID 10

At present, TWRP is not available for Android 11. So we have to downgrade.

Download A10 factory image (version qd4a.200805.003) here: https://dl.google.com/dl/android/aosp/sunfish-qd4a.200805.003-factory-fac7c08d.zip

If you are paranoid like me, check the SHA-256 checksum of the download with some freeware hashing tool. The SHA-256 checksum should be: fac7c08d3d4cb92078fbcdbcc7e80fc4c438612a1a004d3d12814f51928458f3

Extract the files contained in the downloaded archive into the folder where your fastboot.exe is. To be clear, flash-all.bat should be in the same folder as fastboot.exe.

Place your phone in fastboot mode (Vol Down + Power).

Connect your phone to your PC.

In your command prompt type "fastboot devices" to make sure there is proper connection.

Double click "flash-all.bat".

The phone is going to reboot a few times. Just wait patiently until you read "Press any key to exit..." in the command prompt.

You've now downgraded to Android 10!

THIRD

STEP: FLASHING A CUSTOM KERNEL AND TWRP

A custom kernel is needed for TWRP to work, because the stock kernel comes with no LZMA support. Just download the kernel provided by the same developer of TWRP (@nikamura): https://drive.google.com/file/d/1nuXc88t0Iokc0ha-AicOtZEUeGCGwQ-R/view?usp=sharing

And download TWRP, obviously: https://drive.google.com/file/d/1PZaU9PpYmdcAHlyi0zhNwEGnBsAHDW_E/view?usp=sharing

Place both the kernel and TWRP where your fastboot.exe is.

Note that since you just used the factory image you have to boot Android 10 at least once and run the first boot wizard, before you can flash the kernel and TWRP. Also, turn on "USB debug" in Developer Options (see "FIRST STEP" for how to reach Developer Options).

Now, connect your phone to your PC.

In your command prompt type "adb devices". Follow prompt on your phone to permanently allow the adb connection to your pc.

Type the following commands (without quotes):

"adb reboot bootloader"

"fastboot flash boot TKernel-sunfish_V0.1.img"

"fastboot reboot bootloader"

"fastboot boot sunfish_twrp201017-test5.img"

The phone should now boot into TWRP on-the-fly, but it's not been flashed yet.

Place TWRP file on your phone with the following command:

"adb push sunfish_twrp201017-test5.img /sdcard/"

Now in TWRP go to "Install" > "Install Image" > "sunfish_twrp201017-test5.img" > "Install recovery ramdisk" > Swipe.

Now back to the home of TWRP > "Reboot" > "Recovery".

The phone should now boot into TWRP! And this time it's properly installed (not just sideloaded).

You can now reboot into Android 10.

FOURTH STEP: ROOTING WITH MAGISK

Now, you need to grab your current boot image. To do this, boot into TWRP (Vol UP + Power) > "Backup" > flag only "Boot (64MB)" > "Options" tab > unflag "Enable compression" > "Backup" tab > Swipe.

Reboot to Android 10.

Disable "Automatic System Updates" in Developer Options.

Connect phone to PC.

If you browse your phone, in /sdcard/TWRP/BACKUPS/xxxxxxxx/xxxxxxx/ there will be a file named "boot.emmc.win". That's your boot image and you can rename it "boot.img". It should weigh exactly 64MB.

Download Magisk Manager apk (credits @topjohnwu): https://github.com/topjohnwu/Magisk/releases/download/manager-v8.0.7/MagiskManager-v8.0.7.apk

Copy Magisk Manager apk to your device.

Install Magisk Manager apk.

Open Magisk Manager. My locale is not English, so the following commands might slightly differ from what you will see, but still they should be easy to understand. Select 'Install' (Magisk) -> 'Select and Patch File' -> select your boot.img file -> 'Go!' -> it'll output the patched boot image to your Download folder.

Copy the magisk_patched_xxxxxx.img from Download folder to your pc, where your fastboot.exe is.

In your command prompt type:

"adb reboot bootloader"

"fastboot flash boot magisk_patched_xxxxxx.img"

"fastboot reboot bootloader"

You're now rooted!

Enter recovery to make sure TWRP is still working.

Reboot system.

Check in Magisk Manager the resulting installed version of Magisk is 21.4 (=rooted).