Featured image of post Using AutoJS on Redroid: Build, Troubleshooting, and Automation

Using AutoJS on Redroid: Build, Troubleshooting, and Automation

Build a Redroid image with Magisk via redroid-script, resolve su path and Zygisk activation issues, and deploy AutoJS in containers for autostart and automation.

Introduction

In a previous post, I explained how to configure Redroid in Docker and obtain root access with Magisk. As some open-source modules raised their minimum Magisk version requirements, this article adopts ayasa520/redroid-script to rebuild the image and update the root approach. It also introduces AutoJS to handle autostart and automation-click scenarios, documenting the complete flow from building and composing to troubleshooting.

Compliance & Risk Notice
This article is for learning and research only. Operations involving certificates, root, system modules, and network redirection may pose compliance and security risks. Ensure you have proper authorization for any production use or actions involving third-party systems. Device identifiers in the article (e.g., IMEI) are examples—replace them with your own compliant, fictitious values.


Environment & Prerequisites

  • Docker / Docker Compose
  • A Linux host capable of running Redroid
  • ADB / Scrcpy (for debugging and screen casting)
  • Base apps: MT Manager, Termux, AutoJsPro, JustTrustMe
  • Magisk modules: LSPosed, AlwaysTrustUserCerts, Systemless Hosts
  • Unified resource pack (download link at the end)

Build a Redroid Image with Magisk Included

Fetch the script and install dependencies

1
2
3
4
5
git clone https://github.com/ayasa520/redroid-script
cd redroid-script

apt update && apt install -y lzip
pip install -r requirements.txt

Extend Android version choices (example: 14/15)

If you need Android 14/15, add the options in redroid.py:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
def main():
    ...
    parser.add_argument('-a', '--android-version',
                        dest='android',
                        help='Specify the Android version to build',
                        default='11.0.0',
-                        choices=['13.0.0', '12.0.0', '12.0.0_64only', '11.0.0', '10.0.0', '9.0.0', '8.1.0'])
+                        choices=['15.0.0_64only', '15.0.0', '14.0.0_64only', '14.0.0',
+                                 '13.0.0_64only', '13.0.0', '12.0.0', '12.0.0_64only',
+                                 '11.0.0', '10.0.0', '9.0.0', '8.1.0'])

Build the image with Magisk

1
2
python3 redroid.py -a 15.0.0_64only -m
# New image: redroid/redroid:15.0.0_64only_magisk

Launch Redroid

Example docker-compose.yaml:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
name: android
services:
  redroid_15_1:
    image: redroid/redroid:15.0.0_64only_magisk
    container_name: redroid_15_1
    restart: unless-stopped
    privileged: true
    networks:
      android:
        ipv4_address: 172.18.0.252
    ports:
      - "45555:5555"
    volumes:
      - ./redroid_15_1:/data
    command:
      - androidboot.hardware=mt6891
      - androidboot.hwc=CN
      - androidboot.redroid_height=2400
      - androidboot.redroid_width=1080
      - ro.boot.hwc=CN
      - ro.product.manufacturer=Xiaomi
      - ro.product.brand=Xiaomi
      - ro.product.model=2211133C
      - ro.product.marketname=Xiaomi 13
      - ro.product.device=fuxi
      - ro.product.name=fuxi
      - ro.build.product=fuxi
      - ro.product.mod_device=fuxi
      - ro.secure=0
      - ro.product.locale=zh-CN
      - ro.product.locale.language=zh
      - ro.product.locale.region=CN
      - persist.sys.locale=zh-CN
      - persist.sys.locale_list=zh-CN,en-US
      - persist.sys.timezone=Asia/Shanghai
      - persist.sys.time_12_24=24

networks:
  android:
    driver: bridge
    ipam:
      config:
        - subnet: 172.18.0.0/16

Startup & connection:

1
2
3
4
5
6
7
docker compose up -d
docker compose ps
docker compose logs -f redroid_15_1

adb connect 127.0.0.1:45555
adb devices
adb shell whoami

Once running properly, the ADB service is exposed on port 45555. redroid scrcpy


Install Base Apps & Modules

Apps (from the unified pack at the end)

  • MT Manager
  • Termux
  • AutoJsPro
  • JustTrustMe

Magisk modules

  • LSPosed
  • AlwaysTrustUserCerts
  • Systemless Hosts

Recommended order: install the user certificate first (see below), then enable AlwaysTrustUserCerts, and enable/adjust other modules as needed to improve Zygisk activation stability.


Root Authorization & the su Path

Symptoms

  • Running su in Termux correctly triggers the Magisk grant dialog.
  • MT Manager and Shizuku fail to obtain root.
  • logcat shows no obvious errors.

Resolution

Notes Different apps discover and invoke root differently. An explicit path avoids visibility issues caused by environment variables or mount strategies. If you customized PATH, SELinux, or overlayfs, evaluate their impact accordingly.


Troubleshooting Zygisk Not Activating

Symptom Magisk’s Zygisk keeps saying “restart required,” but remains inactive after reboot. Logs are sparse.

Reusable steps

  • Install the user certificate in system settings first.
  • Enable AlwaysTrustUserCerts via LSPosed/module manager.
  • Reboot Redroid so Zygisk and related modules can initialize and mount properly. AlwaysTrustUserCerts

If it still fails, try clearing module caches, check LSPosed version compatibility, and if necessary roll back to a stable Magisk/Redroid combination.


Deploy AutoJS for Automation

Use cases Execute automated clicks, heartbeats, or form-filling after specific apps launch.

Compliance Reminder The following is for your own environment and authorized testing only. Do not apply it to apps or services without explicit permission.

Prepare the AutoJS service

1
2
3
4
5
6
7
# Extract autojserver.tar.gz from the resource pack to your compose directory
tar -zxvf autojserver.tar.gz

cd autojserver
chmod +x main.sh
bash main.sh
# Initialization generates a self-signed certificate and other runtime files

Compose setup

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
name: android
services:
  redroid_15_1:
    image: redroid/redroid:15.0.0_64only_magisk
    container_name: redroid_15_1
    restart: unless-stopped
    privileged: true
    networks:
      android:
        ipv4_address: 172.18.0.252
    ports:
      - "45555:5555"
    volumes:
      - ./redroid_15_1:/data
    command:
      - androidboot.hardware=mt6891
      - androidboot.hwc=CN
      - androidboot.redroid_height=2400
      - androidboot.redroid_width=1080
      - ro.boot.hwc=CN
      - ro.product.manufacturer=Xiaomi
      - ro.product.brand=Xiaomi
      - ro.product.model=2211133C
      - ro.product.marketname=Xiaomi 13
      - ro.product.device=fuxi
      - ro.product.name=fuxi
      - ro.build.product=fuxi
      - ro.product.mod_device=fuxi
      - ro.secure=0
      - ro.product.locale=zh-CN
      - ro.product.locale.language=zh
      - ro.product.locale.region=CN
      - persist.sys.locale=zh-CN
      - persist.sys.locale_list=zh-CN,en-US
      - persist.sys.timezone=Asia/Shanghai
      - persist.sys.time_12_24=24

  autojserver:
    image: autojserver:latest
    build:
      context: ./autojserver
      dockerfile: Dockerfile
    container_name: autojserver
    restart: unless-stopped
    working_dir: /data
    networks:
      android:
        ipv4_address: 172.18.0.251
    command: ["python", "/data/main.py"]
    volumes:
      - ./autojserver:/data

networks:
  android:
    driver: bridge
    ipam:
      config:
        - subnet: 172.18.0.0/16

Start and view logs

1
2
3
docker compose up -d
docker compose ps
docker compose logs -f autojserver

Inject certificates and hosts

1
2
3
4
5
# User certificate: for manual installation in system settings
cp ./autojserver/ca.crt ./redroid_15_1/media/0/Download/

# Systemless Hosts: ensure the module is installed
cp -rf ./autojserver/hosts ./redroid_15_1/adb/modules/hosts/system/etc/

Then, in Settings → Security → Encryption & credentials (or Certificate management) → Install from storage, install the ca.crt user certificate. In JustTrustMe, check AutoJS / target apps in the scope. Reboot Redroid.


Resource Download

Unified resource pack

  • Apps: MT Manager, Termux, AutoJsPro, JustTrustMe
  • Modules: LSPosed, AlwaysTrustUserCerts, Systemless Hosts
Facing the sea with spring blossoms.
Built with Hugo
Theme Stack designed by Jimmy