Running Android on a Raspberry Pi

calendar

July 15, 2022

categories
Guides
tags
android raspberry pi

Content:

It’s now possible to install and run Android 12 on a Raspberry Pi.

This opens up the ability to run Android applications on the device, which could be especially useful if you’re using a Pi with a touchscreen.

Here’s how you can try it out for yourself.

What to Expect

The Raspberry Pi Android image uses an Android build known as LineageOS. LineageOS is essentially a stock build of Android, with no Google services present. The code behind LineageOS is otherwise the same as any other.

With MindTheGapps, it’s possible to add Google services to the device should you wish to do so, though this is a step for later on in the tutorial.

The specific Android build is actually Android 12L – the version designed for larger devices, such as tablets. This will be slightly different for someone used to the phone variant.

It seems all of the core Pi features are present and working, with the exception of hardware video encoding and decoding. This is also an issue in Raspberry Pi OS.

For now, you need to ensure you have a micro SD card at least 8GB in size, and a Raspberry Pi 4 with a minimum of 2GB of RAM. This includes the Compute Module 4.

Installation

The first step is to download the LineageOS build from the KonstaKANG website. You can find the page below – look for the latest download link. You’ll need the full build, without the -ota at the end of the file name.

Extracting the .zip, you’ll find an .img file. This can be flashed to the micro SD card the same way as any other Pi image.

My preferred way to do this is to run

dd if=/path/to/lineage-os-image.img of=/path/to/microsd && sync

but you can use any method you prefer.

Once the image is copied over, you’ll find 4 partitions have been created on the micro SD card, with some unallocated space at the end of the card.

partitions
Partitions on the micro SD card.

At this point, you might want to resize the userdata partition to fill the remaining free space on the card. If you do, you’ll need to boot into TWRP and reformat this partition, to ensure it’s created correctly. You’ll find more details about this later on.

Testing

On first boot, you’ll be greeted with the LineageOS boot animation.

boot animation
Boot animation.

If this is not the case, double-check that the card has been set up correctly, and repeat the previous process if necessary. It took a couple of attempts and a change in USB to micro SD adaptor for it to work correctly for myself.

The system will boot to the initial LineageOS setup screen.

initial setup screen
Initial setup screen.

Using a mouse and keyboard on Android is rather alien, as was using the scroll wheel to navigate menus. It’s a reminder that the OS is very much focused on the touchscreen experience.

With setup complete, you’ll reach the Android home screen.

home
Home screen.

There are few applications pre-installed, but all of the basics are here.

app menu
App menu.

You can install pretty much any Android app on the device – the only exceptions being those not designed for tablets, or those that require specific hardware (looking at you, Pokemon Go).

Installing Google Services

To install Google services on the Pi, you’ll first need to grab the MindTheGapps package.

On the MindTheGapps page, find the version starting MindTheGapps-12.1.0-arm64-. This is the version you’ll need to download.

Copy this to the userdata partition on the micro SD card. Then you’ll first need to boot into TWRP recovery. There are a couple of ways to do this:

  • Use the ‘Reboot to TWRP’ option in the power menu – only available after enabling advanced restart options
  • Ground GPIO pin 21

Once booted into TWRP, use the ‘Install’ option to flash the .zip file you downloaded.

twrp
TWRP menu.

After it’s installed, you can reboot the system. Be sure to remove the GPIO 21 -> GND connection first though, or you’ll end up back in TWRP.

Installing Updates

Once you’ve got a copy of LineageOS installed, it’s possible to update the system without having to start fresh.

The process for doing this is similar to the process for flashing an Android ROM on a phone, so might seem familiar if you’ve done this before.

You’ll need to download the -ota build from KonstaKANG. Save this to either your Pi’s micro SD card, or an external storage device.

Next, you’ll need to reboot into TWRP recovery – the steps to do this are outlined in the previous section.

From here, you can install the update using the ‘Install’ option. If you have any other zip-based addons (such as Magisk), you’ll need to reinstall these too.

Any manual changes made to /boot/config.txt will need to be re-added.

Conclusion

My personal experience of testing is that, while it works perfectly well, it’s a little slow at times (though I’m used to using Pi’s headless). It felt more of a novelty to have Android running on the device, rather than being particularly useful.

That said, if your usage benefits from a touchscreen, and you can hook one up to your Pi, I can see why this would be an attractive option. There are few decent touch-based OS options available for the Pi

On top of that, Android has a wide range of applications available – some of which have no alternative on typical Pi distros.

So while it’s not something I’ll be keeping, it’s worth checking out, and I can certainly think of use-cases where it could prove beneficial.

If you like what we do, consider supporting us on Ko-fi