redroid (Remote Android) Documentation

repository·master·Indexed 27 days ago

https://github.com/remote-android/redroid-doc

Documentation for redroid, a GPU-accelerated Android-in-Cloud (AIC) solution for running multiple Android instances as Docker containers on Linux. It supports arm64 and amd64 architectures for cloud gaming, automation testing, and virtualized phone environments. Includes guides on building from source using the redroid-builder Docker image, integrating GApps, deploying via Docker/Podman, and connecting via ADB and scrcpy.

Tokens
10.5K
Snippets
45
Records
61
Agent score
91%

What's inside redroid

  1. Add binder devices on Debian

    master

    To run redroid on Debian, you must ensure the binder devices are available and have the correct permissions. Use modprobe to load the binder_linux module with specific device nodes and then set the permissions to 666.

    modprobe binder_linux devices=binder1,binder2,binder3,binder4,binder5,binder6
    chmod 666 /dev/binder*
  2. Deploy redroid on Deepin 23

    master

    To deploy redroid on Deepin 23, first install podman using the system package manager. Then, create a data directory and run the redroid container using podman run with privileged access and port mapping.

    # Install podman
    apt install podman
    
    # Start redroid
    mkdir ~/data11
    podman run -itd --rm --privileged \
        --pull always \
        -v ~/data11:/data \
        -p 5555:5555 \
        --name redroid11 \
        redroid/redroid:12.0.0_64only-latest
  3. Build the redroid builder Docker image

    master

    Create a Docker image named redroid-builder that includes the necessary environment for building Android. The build process passes your host's user and group IDs to ensure file permissions are handled correctly within the container.

    docker build --build-arg userid=$(id -u) --build-arg groupid=$(id -g) --build-arg username=$(id -un) -t redroid-builder .
  4. Set up the environment to build Redroid with Docker

    master

    Before building, ensure you have approximately 200GB to 250GB of free disk space. This setup involves installing system packages, configuring repo, setting up Git, and configuring Docker permissions.

    Note: After adding your user to the docker group, you must logout and login again for the changes to take effect.

    # update and install packages
    sudo apt-get update -y && sudo apt-get upgrade -y && sudo apt-get install -y curl libxml2-utils docker.io docker-buildx git-lfs jq
    sudo apt-get remove repo -y && sudo apt-get autoremove -y
    
    # install 'repo'
    mkdir -p ~/.bin
    curl https://storage.googleapis.com/git-repo-downloads/repo > ~/.bin/repo
    chmod a+x ~/.bin/repo
    echo 'export PATH=~/.bin:$PATH' >> ~/.bashrc && source ~/.bashrc
    
    # set git variables
    git config --global user.email "you@example.com"
    git config --global user.name "Your Name"
    
    # add current user to Docker group
    sudo usermod -aG docker ubuntu # Replace 'ubuntu' with your username
    sudo systemctl enable docker
    sudo systemctl restart docker
  5. Deploy redroid on Fedora 38

    master

    To deploy redroid on Fedora 38, you must first disable SELinux and then run the docker container.

    1. Disable SELinux: Use grubby to update kernel arguments and regenerate the grub configuration, then reboot.
    2. Run redroid: Use docker run with the following configuration:
      • --privileged: Required for redroid to function.
      • --pull always: Ensures the latest image is used.
      • -v ~/data11:/data: Mounts a local directory to the /data partition.
      • -p 5555:5555: Exposes the ADB port.
      • --name redroid11: Assigns the container name.
    # Disable SELinux
    grubby --update-kernel ALL --args selinux=0
    grub2-mkconfig > /boot/grub2/grub.cfg
    reboot
    
    # Start redroid
    docker run -itd --rm --privileged \
        --pull always \
        -v ~/data11:/data \
        -p 5555:5555 \
        --name redroid11 \
        redroid/redroid:12.0.0_64only-latest
  6. Fetch and prepare redroid source code

    master

    To build redroid, you must first initialize the Android source tree, add local manifests, sync the code, and apply redroid-specific patches.

    Note: Ensure you check the supported branch in https://github.com/remote-android/redroid-patches.git before starting.

    # 1. Initialize repo with Android manifest
    mkdir ~/redroid && cd ~/redroid
    repo init -u https://android.googlesource.com/platform/manifest --git-lfs --depth=1 -b android-11.0.0_r48
    
    # 2. Add local manifests
    git clone https://github.com/remote-android/local_manifests.git ~/redroid/.repo/local_manifests -b 11.0.0
    
    # 3. Sync code
    repo sync -c
    
    # 4. Apply redroid patches
    git clone https://github.com/remote-android/redroid-patches.git ~/redroid-patches
    ~/redroid-patches/apply-patch.sh ~/redroid
  7. Apply Redroid patches and start the Docker builder

    master

    Apply the necessary Redroid patches to the source code and launch the Docker container used for the build process.

    # Apply redroid patches
    git clone https://github.com/remote-android/redroid-patches.git ~/redroid-patches
    ~/redroid-patches/apply-patch.sh ~/redroid
    
    # Build and run the builder container
    docker buildx create --use
    docker buildx build --build-arg userid=$(id -u) --build-arg groupid=$(id -g) --build-arg username=$(id -un) -t redroid-builder --load .
    docker run -it --privileged --rm --hostname redroid-builder --name redroid-builder -v ~/redroid:/src redroid-builder
  8. Build redroid with GApps (Mind The Gapps)

    master

    To include GApps in your redroid build, follow these steps:

    1. Add Manifest: Create .repo/local_manifests/mindthegapps.xml. Use revision rho for Redroid 11 or sigma for Redroid 12.
    2. Modify device.mk: Add the GApps path to device/redroid/redroid_ARCHITECTURE/device.mk using the $(call inherit-product, ...) syntax.
    3. Sync and Build: Run repo sync -c and proceed with the standard build process.

    Tip: To skip the GApps setup wizard, use the entrypoint: ENTRYPOINT ["/init", "androidboot.hardware=redroid", "ro.setupwizard.mode=DISABLED"] during the docker import step.

    <!-- Example .repo/local_manifests/mindthegapps.xml -->
    <?xml version="1.0" encoding="UTF-8"?>
    <manifest>
        <remote name="mtg" fetch="https://gitlab.com/MindTheGapps/" />
        <project path="vendor/gapps" name="vendor_gapps" revision="sigma" remote="mtg" />
    </manifest>
    # Example addition to device/redroid/redroid_x86_64/device.mk
    $(call inherit-product, vendor/gapps/x86_64/x86_64-vendor.mk)
  9. Configure kernel features for redroid on x86_64 CentOS

    master

    To run redroid on x86_64 CentOS, ensure your kernel is compiled with the following configuration options. These enable essential features like DMA-BUF heaps, ashmem, and binderfs.

    # codec2 required, can use ION for legacy kernel
    CONFIG_DMABUF_HEAPS=y
    CONFIG_DMABUF_HEAPS_SYSTEM=y
    
    # optional, can use memfd
    CONFIG_STAGING=y
    CONFIG_ASHMEM=y
    
    # binderfs required
    CONFIG_ANDROID=y
    CONFIG_ANDROID_BINDER_IPC=y
    CONFIG_ANDROID_BINDERFS=y
    CONFIG_ANDROID_BINDER_DEVICES="binder,hwbinder,vndbinder"