ReDroid (Remote anDroid) is an open source and self-hosting “cloud phone” solution. By running Android in containers on Linux PC, we could access Android desktop by using Scrcpy. And the container could be accessed remotely.
Here is my demonstration of what “self-hosting cloud phone” looks like. In this video, I install Scrcpy client on iPhone and connect to Linux PC using Zerotier to play Android games remotely. (sorry my video is in Chinese)
ReDroid is also one of the few solutions to run Android APP on Linux with open source software. Many Android simulators, not to mention cloud phones, are closed source. In contrast, ReDroid is an open source solution except for the ARM translator. Even better, ReDroid supports GPU acceleration plus ARM translations, so you can play more mobile 3D games!
ReDroid is much light-weight and easy to deploy than Android-x86 VM.
If you ask me, there is already a similar, container-based solution, which is known as Waydroid for playing Android games. Why do I choose ReDroid over Waydroid? Well freak Nvidia. Waydroid does not work on Nvidia GPU.
In this article, I will discuss how to use ReDroid to play mobile games on Linux PC. We will setup a container, and add ARM translator + Google Service Framework to the ReDroid image for the best experience.
1. Prerequisites
If you want to use ReDroid to play mobile games, it is recommended that you have at least 8GB of RAM on your PC, because sometimes ARM translator will take up a lot of RAM when translating ARM to x86 instructions.
There are installation instructions for all Linux distributions of ReDroid on Github, include WSL.
- Since I am using Arch Linux, I have to change the kernel to
linux-zen
. After installing the linux-zen kernel, update the GRUB options. Reboot and selectlinux-zen
kernel in Advanced Options of GRUB menu.
|
|
Install Docker to run the container.
Install ADB and Scrcpy. Scrcpy now includes sndcpy.
|
|
* If you want a graphical Scrcpy frontend with key mapping, you can install QtScrcpy instead.
2. Launch ReDroid
Most computers are x86 architecture, and can only run x86 version of Android APP. However, many mobile games only have ARM version, so ReDroid needs a ARM translator.
The redroid:11.0.0-latest
and redroid:12.0.0-latest
images released by the author of ReDroid have built-in libndk, an ARM translator developed by Google. From what I test, Android 11 image is the stable version, and the Gapps can be isntalled, so we will take Android 11 as an example.
- Create a directory for storing your data. Create docker-compose.
|
|
- Fill in the following
|
|
- Start the container
|
|
- Connect to the local ReDroid using ADB:
|
|
- Run Scrcpy to connect to the Android desktop:
|
|
- This will bring you to the Android desktop.
3. Install Google Service Framework (GAPPS)
The author says that Google Service Framework is proprietary software and cannot be built-in in ReDroid, so you have to install it by yourself. The first method is to recompile the Android image. Tthe second is to install OpenGApps manually.
The first method is not recommended, it’s time consuming and the GApps compilation tutorial provided by the author has problems that the gapps can’t be detected by other apps.
Here I choose the second method: manual installation of gapps. Reference: Install GApps Manually - Google Groups
Go to OpenGapps. Download Android 11 GApps with x86_64 architecture, and choose the minimized pico version.
Unzip it and you will see the following directory
|
|
Create a folder named
system
underopen_gapps-x86_64-11.0-pico-20220503
Next, extract the
.lz
files in theCore
andGApps
directories and move the APK in thesystem
directory to the corresponding installation directory. For example, theGoogleTTS
directory underGApps/googletts-x86_64/nodpi/app/
should be placed in/system/app
.So the directory structure under
system
should look like this:
|
|
- Execute the following command to obtain root privileges:
|
|
- Then push the
system
directory to the ReDroid system and give it permission:
|
|
- Reboot the ReDroid container:
|
|
- Starting Scrcpy
|
|
Open System Settings → Apps, tap “Show System Apps” in the upper right corner, and turn on both Google Play Services and Play Store permissions.
Run the following command to get the Android device ID, go to Google website to register the device, wait for 30 minutes and restart the Redroid container to login to Google Play.
|
|
4. Install APK to ReDroid
At present, even if you have installed libndk, the Play Store still doesn’t allow you to download apps with ARM architecture, so please install apps from APKPure or other app stores.
In addition to using the container’s internal browser to download APK, you can also use ADB to install APK to ReDroid container. For example, go to ApkMirror to download the APK of Line, and then install it with ADB:
|
|
You can also transfer files using ADB’s pull
and push
commands.
For screen resolution adjustment, see the instructions for ReDroid and Scrcpy.
5. How to “turn off” ReDroid
To shut down ReDroid, close the Scrcpy window and stop the container:
|
|
You can then use following command to start ReDroid. the /data
data for the ReDroid container is located in the ~/redroid/redroid-11-data
directory, which can be used to back up files from multiple systems.
|
|
For your reference: Manually extracting libndk from Android Studio emulators
libndk is a proprietary software developed by Google, which is included in Android Studio emulator. According to the ReDroid author’s instructions, we can manually extract libndk from the new version of Android emulator and add it to lastest ReDroid image.
Taking Android 13 as an example, note that the author does not guarantee that this will work.
Install Android Studio and add a new virtual machine for Android 13.
Connect to the emulator via ADB
|
|
- Create a archive of libndk
|
|
- Create a archive of libndk.so
|
|
- Exit ADB and transfer the above files back to the host
|
|
- Add libndk.so to libndk’s archive.
|
|
- Creatr a
DOCKEEFILE
with the following contents:
|
|
- Start building the Android 13 image with libndk, then the image
redroid:13.0.0-libndk
can be used to run the other containers.
|
|