In this article you’ll learn how to bring touchscreen support by installing Android 9.0 on Raspberry Pi 4. While the user experience can sometimes feel awkward and laggy, you’ll have multi-touch and touchscreen support, access to a huge variety of Android apps, and the bragging rights that you managed to get Android up and running on Raspberry Pi!
What you’ll need
To complete this tutorial, you’ll need:
A Raspberry Pi 4An SD cardA laptop or computer where you’ll download the Android 9.0 system imageA power cable that’s compatible with your Raspberry PiA micro HDMI cableAn external monitor, or, if you want that authentic Android experience, a screen that has touchscreen supportAn external keyboard and a way to attach this keyboard to your Raspberry PiA mouse or the trackpad on your external keyboardOptionally, an ethernet cable
Once you’ve assembled your tools, you’re ready to get Android 9.0 running on Raspberry Pi!
Downloading LineageOS 16.0
We’re using a build of LineageOS 16.0 as the base Android 9.0 image. Do note that this build is unofficial and unsupported by the LineageOS team, and it typically isn’t suitable for performing intensive tasks, such as playing games or streaming high-resolution media. We’re flashing this system image to our SD card using the free Etcher application, so if you don’t already have this set up on your computer or laptop, then head over to the balenaEtcher website and download the latest version.
Head over to the KonstaKANG website and download LineageOS 16.0. Insert the SD card into your laptop or computer. Launch the Etcher application.In Etcher, click “Select image” and then choose the LineageOS file you just downloaded.Click “Select target” and choose your target boot medium, which in this instance is the SD card.
Etcher will now flash the system image to the SD card.
Running Android on Raspberry Pi
You’re now ready to get your first taste of Android running on the Raspberry Pi! You’ll now be taken to the main Android screen.
Don’t forget about Google Play!
Android should now be up and running, but LineageOS doesn’t come with Google Play installed. To get Google Play, download and install GApps, which includes Google Play and all the services required to power this application. The Device ID APK is needed as well, which will be used to generate a code that identifies the device and allows us to connect to Google Play.
Launch the web browser that comes pre-installed on Android and head to the GApps website.Select “ARM,” “Android 9” and “Pico,” and then click the “Download” icon.
Next, head to the APKMirror website and download the Device ID APK.
Moving the GApps file
To make the next steps easier, drag the GApps file to the root of your storage: This file will now be easier to find when we boot into Recovery mode.
Unlock Android’s hidden Developer Options
Developer Options need to be enabled, which will give you access to the Terminal: You can now exit the “Settings” application. Raspberry Pi needs to be rebooted in order to gain access to the Terminal, so press the F5 key on the keyboard, which will open a “Power” menu where you can select “Restart.”
Boot into Android’s Recovery Mode
To boot into Recovery Mode:
- Open the app drawer by dragging upwards from the bottom of the screen.
- Select “Terminal.”
- Type the following command into the Terminal window:
- Press the “Enter” key on your keyboard. When prompted, select “Remember my choice” followed by “Allow.”
- Type the following command into the Terminal: Press the Enter key and run the following command: Press Enter. Android will now reboot into Recovery Mode.
Install GApps and wipe the Dalvik cache
To install GApps:
- In Recovery mode, find the “Swipe to allow modifications” slider and drag it to the “On” position.
- Select “Install” and find the GApps package you downloaded earlier.
- Give GApps a tap, then drag the “Swipe to confirm Flash” slider. GApps will now be installed.
- Wipe the Dalvik cache by dragging the “Swipe to wipe” slider.
- When you see the “Dalvik wipe complete” screen, click the “Back” button.
- In the upper-left corner, select the “Team Win Recovery Project” icon, which will take you back to the main menu.
- Click “Wipe.”
- Drag the “Swipe to Factory Reset” slider.
- When prompted, click “Back.” In the upper-left corner, select the “Team Win Recovery” button which will once again take you back to the main menu.
- Click “Mount.”
- Make sure “Boot,” “System” and “Data” are all selected, then return to the main screen by clicking the “Team Win Recovery Project” icon.
- Click “Advanced -> Terminal.”
- To reboot the system from Terminal, type: Press the Enter key on your keyboard.
- Type the following command into the Terminal: Press Enter. The system will now reboot. Once Android has booted, you may need to perform some extra configuration: for example, agreeing to the Google Terms and Conditions and setting up a protective PIN. Once you’ve completed this setup, there should be a new addition to your homescreen: Google Play is now installed on your device! However, there’s a catch: if you try to launch the Google Play application, then you’ll encounter a warning that your device isn’t Play Protect-certified. The final task is to generate a code using the Device ID APK, then using this code to authenticate the device.
Get Play Protected: Registering with Google
To generate the Device ID code:
Open the app drawer by dragging from the bottom of the screen, then selecting “Files.”Navigate to the “Downloads” folder. Find the Device ID APK that you downloaded earlier and double-click to launch. When prompted, select “Install.” Open the app drawer and select the newly-installed Device ID application. Once the app has launched, click “Google Service Framework.” A code will appear in a pop-up. Click “Copy.” Towards the top of the screen, you should see a “Device is not Play Protect certified” warning. Click this to launch a popup. In the pop-up, scroll to the “Custom ROM users” section and click the accompanying link. This will launch Android’s default web browser.When prompted, log into your Gmail account.Once you’re logged in, paste the code from the Device ID APK and paste it into the “Register” field.Select “Register.” Google will now register this device as a custom ROM and allow you to access Google Play.
Your changes only become active following a reboot, so use the F5 key to reboot the system. When your Raspberry Pi has performed its reboot, launch the Google Play app, sign in with your Gmail account, and you’re ready to start downloading Android apps to the Raspberry Pi 4! If you receive an error message when trying to access Google Play for the first time, then try waiting for around 15 minutes, as there can sometimes be a delay before Google successfully registers your ID. Although Android 9.0 wasn’t designed for Raspberry Pi, it offers a unique combination of touchscreen support and access to an entire ecosystem of Android apps. Other than that, there are also many other ways to put the Raspberry Pi 4 to good use.