|
| 1 | +--- |
| 2 | +outline: [2, 3] |
| 3 | +description: Deploy a cloud Android emulator using redroid on Olares, and access the Android host from macOS and Windows via adb and scrcpy. |
| 4 | +--- |
| 5 | + |
| 6 | +# Host your cloud Android with redroid |
| 7 | + |
| 8 | +[redroid](https://github.com/remote-android/redroid-doc) (Remote Android) is a GPU-accelerated Android-in-Cloud (AIC) solution that integrates seamlessly with Olares. You can easily host high-performance Android instances on your Olares and access them anytime to run Android games, apps, or even automation tests. |
| 9 | + |
| 10 | +This tutorial walks you through installing redroid on Olares and accessing the Android instance from Windows and macOS. |
| 11 | + |
| 12 | +## Objectives |
| 13 | + |
| 14 | +By the end of this tutorial, you will learn how to: |
| 15 | +- Install the required Linux kernel modules on the Olares host. |
| 16 | +- Install the redroid app on Olares and get the service URL. |
| 17 | +- Connect and operate the Android instance from Windows and macOS, using `adb` and `scrcpy`. |
| 18 | +- Install APK apps on the Android instance. |
| 19 | + |
| 20 | +## Before you begin |
| 21 | + |
| 22 | +Make sure the following requirements are met: |
| 23 | +- Olares is installed and running on a Linux machine. |
| 24 | + ::: tip Configuration requirements |
| 25 | + - redroid is only supported on Linux. Make sure your Olares instance is running on a Linux system. |
| 26 | + - redroid is resource-intensive. For best performance, we recommend using a machine with at least an 8-core CPU and 16GB of RAM. |
| 27 | + ::: |
| 28 | + |
| 29 | +- Your device and Olares are on the same local network. |
| 30 | + |
| 31 | + :::tip Remote access |
| 32 | + If your device is on a different network, use [LarePass](https://olares.xyz/larepass) to enable a private network connection to Olares. |
| 33 | + ::: |
| 34 | + |
| 35 | +## Install dependent kernel modules |
| 36 | + |
| 37 | +redroid requires specific kernel modules to run on Linux. For details, refer to the [official redroid docs](https://github.com/remote-android/redroid-doc/blob/master/deploy/README.md). |
| 38 | + |
| 39 | +For example, on Ubuntu, you can install the required kernel modules by running the following commands in the terminal: |
| 40 | + |
| 41 | +```bash |
| 42 | +sudo apt install linux-modules-extra-`uname -r` |
| 43 | +sudo modprobe binder_linux devices="binder,hwbinder,vndbinder" |
| 44 | +# This command might fail on newer kernels; the error can be safely ignored. |
| 45 | +sudo modprobe ashmem_linux |
| 46 | +``` |
| 47 | + |
| 48 | +## Install redroid on Olares |
| 49 | + |
| 50 | +redroid runs as a headless backend on Olares. To install redroid: |
| 51 | + |
| 52 | +1. In Olares Market, find redroid under "Utilities", and click **Get**. redroid will launch automatically after installation. |
| 53 | + |
| 54 | +2. Get the URL to access the redroid service: |
| 55 | + |
| 56 | + a. From Olares Desktop, navigate to **Settings** > **Application** > **redroid**. |
| 57 | + |
| 58 | + b. In **Entrances** > **Set up endpoint**, get the base domain of redroid, e.g., `beb583c3.<olares_id>.olares.com`. |
| 59 | + |
| 60 | + c. Append the exported port of redroid (`46878`) to the base domain. |
| 61 | + |
| 62 | + As redroid only allows local access, the domain should also include `.local`. Here is an example of our final URL to access the redroid service: `beb583c3.local.olares01.olares.com:46878`. |
| 63 | + |
| 64 | +## Connect to the redroid service |
| 65 | + |
| 66 | +To access the Android instance on Olares, you'll need to connect to the redroid service using `adb` and render the UI using `scrcpy`. |
| 67 | + |
| 68 | +<tabs> |
| 69 | +<template #Windows> |
| 70 | + |
| 71 | + The Windows version comes bundled with `adb`, so you don't need to install it separately. |
| 72 | + |
| 73 | +1. Download the Windows version of `scrcpy` from the [project website](https://github.com/Genymobile/scrcpy/blob/master/doc/windows.md) and extract it to a specific folder. |
| 74 | + |
| 75 | + ::: tip adb version conflict |
| 76 | + If another version of `adb` is installed, it may cause conflicts between `adb` servers. Uninstall the old version or replace it with the bundled version in `scrcpy`. |
| 77 | + ::: |
| 78 | + |
| 79 | +2. Open PowerShell, then navigate to the `scrcpy` directory: |
| 80 | + |
| 81 | + ```powershell |
| 82 | + # Replace with the acutal path |
| 83 | + cd .\scrcpy-win64-v3.1 |
| 84 | + ``` |
| 85 | +
|
| 86 | +3. Use `adb` to connect to the redroid service via the URL obtained earlier: |
| 87 | +
|
| 88 | + ```powershell |
| 89 | + .\adb.exe connect beb583c3.local.<olares_id>.olares.cn:46878 |
| 90 | + ``` |
| 91 | +
|
| 92 | + The connection is successful if you see the example output: |
| 93 | +
|
| 94 | + ```powershell |
| 95 | + # Example output: |
| 96 | + already connected to beb583c3.local.<olares_id>.olares.cn:46878 |
| 97 | + ``` |
| 98 | +
|
| 99 | +4. Render UI and audio using `scrcpy`: |
| 100 | +
|
| 101 | + ```powershell |
| 102 | + .\scrcpy.exe -s beb583c3.local.<olares_id>.olares.cn:46878 --audio-codec=aac --audio-encoder=OMX.google.aac.encoder |
| 103 | + ```` |
| 104 | + |
| 105 | + Upon successful execution, the command line outputs the device and rendering info. And the Android screen pops up. |
| 106 | + |
| 107 | +  |
| 108 | +</template> |
| 109 | +<template #macOS> |
| 110 | +
|
| 111 | +On macOS, `scrcpy` does not include `adb` by default, so you'll need to install them separately. It is recommended to install them via Homebrew. |
| 112 | +
|
| 113 | +1. Install `scrcpy`: |
| 114 | +
|
| 115 | + ```bash |
| 116 | + brew install scrcpy |
| 117 | + ``` |
| 118 | +
|
| 119 | +2. Install `adb`: |
| 120 | +
|
| 121 | + ```bash |
| 122 | + brew install --cask android-platform-tools |
| 123 | + ``` |
| 124 | +
|
| 125 | +3. Verify the installation: |
| 126 | +
|
| 127 | + ```bash |
| 128 | + scrcpy --version |
| 129 | + adb version |
| 130 | + ``` |
| 131 | + Installation is successful if you see the version numbers. |
| 132 | +
|
| 133 | + :::tip Gatekeeper alert |
| 134 | + If blocked by macOS security, go to **System Settings** > **Privacy & Security** > **Security**, find the corresponding item, and click **Allow Anyway**. You will be promoted to enter your password when re-running the command. |
| 135 | + ::: |
| 136 | +
|
| 137 | +4. Connect to the redroid service URL obtained earlier via `adb`: |
| 138 | +
|
| 139 | + ```bash |
| 140 | + adb connect beb583c3.local.<olares_id>.olares.cn:46878 |
| 141 | + ``` |
| 142 | +
|
| 143 | + The connection is successful if you see the example output. |
| 144 | +
|
| 145 | + ```bash |
| 146 | + # Example output: |
| 147 | + already connected to beb583c3.local.<olares_id>.olares.cn:46878 |
| 148 | + ``` |
| 149 | +
|
| 150 | +5. Render UI and audio using `scrcpy`: |
| 151 | +
|
| 152 | + ```bash |
| 153 | + scrcpy -s beb583c3.local.<olares_id>.olares.cn:46878 --audio-codec=aac --audio-encoder=OMX.google.aac.encoder |
| 154 | + ``` |
| 155 | + Upon success, the command line outputs the device information. The Android screen pops up. |
| 156 | +
|
| 157 | +  |
| 158 | +</template> |
| 159 | +</tabs> |
| 160 | +
|
| 161 | + |
| 162 | +
|
| 163 | +## Install APK |
| 164 | +
|
| 165 | +Once connected, you can use `adb` to install third-party APK apps on the Android instance. |
| 166 | +
|
| 167 | +<tabs> |
| 168 | +<template #Windows> |
| 169 | +
|
| 170 | +1. Get the details of all connected devices: |
| 171 | +
|
| 172 | + ```powershell |
| 173 | + .\adb.exe devices -l |
| 174 | + ``` |
| 175 | +
|
| 176 | + Get the `transport_id` of the device, which is `4` in our case: |
| 177 | +
|
| 178 | + ```powershell |
| 179 | + # Example output |
| 180 | + List of devices attached |
| 181 | + beb583c3.local.<olares_id>.olares.com:46878 device |
| 182 | + product:ziyi model:23031PN0DC device:ziyi |
| 183 | + transport_id:4 |
| 184 | + ``` |
| 185 | +
|
| 186 | +2. Install the APK to the specified device. Use `-t` to specify the transport ID: |
| 187 | +
|
| 188 | + ```powershell |
| 189 | + .\adb.exe -t 4 install C:\Users\YourName\Downloads\your_app.apk\ |
| 190 | + ``` |
| 191 | + |
| 192 | +
|
| 193 | + The installation is successful if you see the following message: |
| 194 | + |
| 195 | + ```powershell |
| 196 | + # Expected output |
| 197 | + Performing Streamed Install |
| 198 | + Success |
| 199 | + ``` |
| 200 | +</template> |
| 201 | +<template #macOS> |
| 202 | +
|
| 203 | +1. Get the details of all connected devices: |
| 204 | +
|
| 205 | + ```bash |
| 206 | + adb devices -l |
| 207 | + ``` |
| 208 | +
|
| 209 | + Get the `transport_id` of the device, which is `4` in our case: |
| 210 | +
|
| 211 | + ```bash |
| 212 | + # Example output |
| 213 | + List of devices attached |
| 214 | + beb583c3.local.<olares_id>.olares.com:46878 device |
| 215 | + product:ziyi model:23031PN0DC device:ziyi |
| 216 | + transport_id:4 |
| 217 | + ``` |
| 218 | +
|
| 219 | +2. Install the APK to the specified device. Use `-t` to specify the transport ID: |
| 220 | +
|
| 221 | + ```bash |
| 222 | + adb -t 4 install ~/Downloads/your_app.apk |
| 223 | + ``` |
| 224 | + |
| 225 | + The installation is successful if you see the following message: |
| 226 | + |
| 227 | + ```bash |
| 228 | + # Expected output |
| 229 | + Performing Streamed Install |
| 230 | + Success |
| 231 | + ``` |
| 232 | +
|
| 233 | +</template> |
| 234 | +</tabs> |
| 235 | +
|
| 236 | +After installation, run `scrcpy` again to render the Android screen. Swipe up to see the installed APK. |
| 237 | +
|
| 238 | +## Common `adb` commands |
| 239 | +
|
| 240 | +:::tip Note |
| 241 | +The following commands are for macOS and Linux. On Windows, replace `adb` with `adb.exe`. |
| 242 | +::: |
| 243 | +
|
| 244 | +```bash |
| 245 | +# Start adb server |
| 246 | +adb start-server |
| 247 | +
|
| 248 | +# Connect to a device |
| 249 | +adb connect <url>:<port> |
| 250 | +
|
| 251 | +# List connected devices |
| 252 | +adb devices |
| 253 | +
|
| 254 | +# Disconnect a device |
| 255 | +adb disconnect <url>:<port> |
| 256 | +
|
| 257 | +# Install an APK by transport_id |
| 258 | +adb -t 3 install your_app.apk |
| 259 | +
|
| 260 | +# View real-time logs |
| 261 | +adb logcat |
| 262 | +
|
| 263 | +# Export logs to a file |
| 264 | +adb logcat -v time > log.txt |
| 265 | +
|
| 266 | +# Push a file to the device |
| 267 | +adb push <local_path> <device_path> |
| 268 | +
|
| 269 | +# Pull a file from the device |
| 270 | +adb pull <device_path> <local_path> |
| 271 | +
|
| 272 | +# List directory contents on device |
| 273 | +adb shell ls <path> |
| 274 | +
|
| 275 | +# View file contents |
| 276 | +adb shell cat <file_path> |
| 277 | +
|
| 278 | +# Reboot the device |
| 279 | +adb shell reboot |
| 280 | +
|
| 281 | +# Shut down the device |
| 282 | +adb shell reboot -p |
| 283 | +``` |
0 commit comments