Skip to content
 
 

Repository files navigation

rootAVD fork

Compatibility

System image family API level CPU/ABI Status Notes
Google Play Store 37.0 arm64-v8a ✔️ Tested working
Google Play Store 36.1 arm64-v8a ✔️ Tested working
Google Play Store 36.1 x86_64 ✔️ Tested working
Legacy 32-bit images 24-30 x86, armeabi-v7a Not retested in this fork

See CompatibilityChart.md for the historical upstream matrix and notes.

This fork is maintained for private/local Android Studio AVD workflows. The upstream project moved to GitLab on 24 Oct 2023: rootAVD.

The fork preserves the public rootAVD.sh and rootAVD.bat command interface, but the Unix implementation has been split into focused modules under lib/rootavd/. A single-file release artifact can still be generated with tools/build-rootavd-bundle.sh.

Current fork status:

  • API level 37.0 Google Play Store arm64-v8a has been tested successfully.
  • API level 36.1 Google Play Store arm64-v8a has been smoke-tested with the modular source checkout: patch, cold boot, Magisk launch, restore, and post-restore su failure were verified.
  • API level 36.1 Google Play Store x86_64 has been tested successfully.
  • Generated bundle patch flow remains to be smoke-tested from a bundle-only directory before publishing a single-file release artifact.
  • Historical and specialized features such as FAKEBOOTIMG, PATCHFSTAB, kernel-module replacement, BLUESTACKS, and Windows wrapper execution should be treated as optional/manual evidence unless they are part of the target use case.

A Script to...

  • root your Android Studio Virtual Device (AVD), with Magisk (Stable, Canary or Alpha)
  • patch its fstab
  • download and install the USB HOST Permissions Module for Magisk
  • install custom build Kernel and its Modules
  • download and install AOSP prebuilt Kernel and its Modules

...within seconds.

Install Magisk

Download rootAVD via

  • Click
  • git clone https://gitlab.com/newbit/rootAVD.git

Preconditions

  • the AVD is running
  • a working Internet connection for the Menu
  • a command prompt / terminal is opened
  • adb shell will connect to the running AVD

Use Case Examples

How to Install ADB (Android SDK Platform-Tools)

  • Open Android Studio -> SDK Manager -> Android SDK -> SDK Tools -> Check on Android SDK Platform-Tools -> Apply

rootAVD Help Menu

rootAVD A Script to root AVD by NewBit XDA

Usage:  rootAVD [DIR/ramdisk.img] [OPTIONS] | [EXTRA ARGUMENTS]
or:     rootAVD [ARGUMENTS]

Arguments:
        ListAllAVDs                     Lists Command Examples for ALL installed AVDs

        InstallApps                     Just install all APKs placed in the Apps folder

Main operation mode:
        DIR                             a path to an AVD system-image
                                        - must always be the 1st Argument after rootAVD

ADB Path | Ramdisk DIR| ANDROID_HOME:
        [M]ac/Darwin:                   export PATH=~/Library/Android/sdk/platform-tools:$PATH
                                        export PATH=$ANDROID_HOME/platform-tools:$PATH
                                        system-images/android-$API/google_apis_playstore/x86_64/

        [L]inux:                        export PATH=~/Android/Sdk/platform-tools:$PATH
                                        export PATH=$ANDROID_HOME/platform-tools:$PATH
                                        system-images/android-$API/google_apis_playstore/x86_64/

        [W]indows:                      set PATH=%LOCALAPPDATA%\Android\Sdk\platform-tools;%PATH%
                                        system-images\android-$API\google_apis_playstore\x86_64\

        ANDROID_HOME:                   By default, the script uses %LOCALAPPDATA%, to set its Android Home
                                        directory, search for AVD system-images and ADB binarys. This behaviour
                                        can be overwritten by setting the ANDROID_HOME variable.
                                        e.g. set ANDROID_HOME=%USERPROFILE%\Downloads\sdk

        $API:                           25,29,30,31,32,33,34,35,36,36.1,37.0,etc.

Options:
        restore                         restore all existing .backup files, but doesn't delete them
                                        - the AVD doesn't need to be running
                                        - no other Argument after will be processed

        InstallKernelModules            install custom build kernel and its modules into ramdisk.img
                                        - kernel (bzImage) and its modules (initramfs.img) are inside rootAVD
                                        - both files will be deleted after installation

        InstallPrebuiltKernelModules    download and install an AOSP prebuilt kernel and its modules into ramdisk.img
                                        - similar to InstallKernelModules, but the AVD needs to be online

Options are exclusive, only one at the time will be processed.

Extra Arguments:
        DEBUG                           Debugging Mode, prevents rootAVD to pull back any patched file

        PATCHFSTAB                      fstab.ranchu will get patched to automount Block Devices like /dev/block/sda1
                                        - other entries can be added in the script as well
                                        - a custom build Kernel might be necessary

        GetUSBHPmodZ                    The USB HOST Permissions Module Zip will be downloaded into /sdcard/Download

        FAKEBOOTIMG                     Creates a fake Boot.img file that can directly be patched from the Magisk APP
                                        - Magisk will be launched to patch the fake Boot.img within 60s
                                        - the fake Boot.img will be placed under /sdcard/Download/fakeboot.img

Extra Arguments can be combined, there is no particular order.

Notes: rootAVD will
- always create .backup files of ramdisk*.img and kernel-ranchu
- replace both when done patching
- show a Menu, to choose the Magisk Version (Stable || Canary || Alpha), if the AVD is online
- make the choosen Magisk Version to its local
- install all APKs placed in the Apps folder
- use %LOCALAPPDATA%\Android\Sdk to search for AVD system images

Linux & MacOS

Command Examples:
./rootAVD.sh
./rootAVD.sh ListAllAVDs
./rootAVD.sh InstallApps

./rootAVD.sh system-images/android-33/google_apis_playstore/x86_64/ramdisk.img
./rootAVD.sh system-images/android-33/google_apis_playstore/x86_64/ramdisk.img FAKEBOOTIMG
./rootAVD.sh system-images/android-33/google_apis_playstore/x86_64/ramdisk.img DEBUG PATCHFSTAB GetUSBHPmodZ
./rootAVD.sh system-images/android-33/google_apis_playstore/x86_64/ramdisk.img restore
./rootAVD.sh system-images/android-33/google_apis_playstore/x86_64/ramdisk.img InstallKernelModules
./rootAVD.sh system-images/android-33/google_apis_playstore/x86_64/ramdisk.img InstallPrebuiltKernelModules
./rootAVD.sh system-images/android-33/google_apis_playstore/x86_64/ramdisk.img InstallPrebuiltKernelModules GetUSBHPmodZ PATCHFSTAB DEBUG
./rootAVD.sh system-images/android-33/google_apis_playstore/x86_64/ramdisk.img AddRCscripts
Command Examples: for ALL installed AVDs
./rootAVD.sh
./rootAVD.sh ListAllAVDs
./rootAVD.sh InstallApps

./rootAVD.sh system-images/android-25/google_apis/armeabi-v7a/ramdisk.img
./rootAVD.sh system-images/android-25/google_apis/armeabi-v7a/ramdisk.img FAKEBOOTIMG
./rootAVD.sh system-images/android-25/google_apis/armeabi-v7a/ramdisk.img DEBUG PATCHFSTAB GetUSBHPmodZ
./rootAVD.sh system-images/android-25/google_apis/armeabi-v7a/ramdisk.img restore
./rootAVD.sh system-images/android-25/google_apis/armeabi-v7a/ramdisk.img InstallKernelModules
./rootAVD.sh system-images/android-25/google_apis/armeabi-v7a/ramdisk.img InstallPrebuiltKernelModules
./rootAVD.sh system-images/android-25/google_apis/armeabi-v7a/ramdisk.img InstallPrebuiltKernelModules GetUSBHPmodZ PATCHFSTAB DEBUG
./rootAVD.sh system-images/android-25/google_apis/armeabi-v7a/ramdisk.img AddRCscripts

./rootAVD.sh system-images/android-25/google_apis/x86_64/ramdisk.img
./rootAVD.sh system-images/android-25/google_apis/x86_64/ramdisk.img FAKEBOOTIMG
./rootAVD.sh system-images/android-25/google_apis/x86_64/ramdisk.img DEBUG PATCHFSTAB GetUSBHPmodZ
./rootAVD.sh system-images/android-25/google_apis/x86_64/ramdisk.img restore
./rootAVD.sh system-images/android-25/google_apis/x86_64/ramdisk.img InstallKernelModules
./rootAVD.sh system-images/android-25/google_apis/x86_64/ramdisk.img InstallPrebuiltKernelModules
./rootAVD.sh system-images/android-25/google_apis/x86_64/ramdisk.img InstallPrebuiltKernelModules GetUSBHPmodZ PATCHFSTAB DEBUG
./rootAVD.sh system-images/android-25/google_apis/x86_64/ramdisk.img AddRCscripts

./rootAVD.sh system-images/android-30/google_apis_playstore/x86/ramdisk.img
./rootAVD.sh system-images/android-30/google_apis_playstore/x86/ramdisk.img FAKEBOOTIMG
./rootAVD.sh system-images/android-30/google_apis_playstore/x86/ramdisk.img DEBUG PATCHFSTAB GetUSBHPmodZ
./rootAVD.sh system-images/android-30/google_apis_playstore/x86/ramdisk.img restore
./rootAVD.sh system-images/android-30/google_apis_playstore/x86/ramdisk.img InstallKernelModules
./rootAVD.sh system-images/android-30/google_apis_playstore/x86/ramdisk.img InstallPrebuiltKernelModules
./rootAVD.sh system-images/android-30/google_apis_playstore/x86/ramdisk.img InstallPrebuiltKernelModules GetUSBHPmodZ PATCHFSTAB DEBUG
./rootAVD.sh system-images/android-30/google_apis_playstore/x86/ramdisk.img AddRCscripts

./rootAVD.sh system-images/android-30/android-automotive-playstore/x86_64/ramdisk-qemu.img
./rootAVD.sh system-images/android-30/android-automotive-playstore/x86_64/ramdisk-qemu.img FAKEBOOTIMG
./rootAVD.sh system-images/android-30/android-automotive-playstore/x86_64/ramdisk-qemu.img DEBUG PATCHFSTAB GetUSBHPmodZ
./rootAVD.sh system-images/android-30/android-automotive-playstore/x86_64/ramdisk-qemu.img restore
./rootAVD.sh system-images/android-30/android-automotive-playstore/x86_64/ramdisk-qemu.img InstallKernelModules
./rootAVD.sh system-images/android-30/android-automotive-playstore/x86_64/ramdisk-qemu.img InstallPrebuiltKernelModules
./rootAVD.sh system-images/android-30/android-automotive-playstore/x86_64/ramdisk-qemu.img InstallPrebuiltKernelModules GetUSBHPmodZ PATCHFSTAB DEBUG
./rootAVD.sh system-images/android-30/android-automotive-playstore/x86_64/ramdisk-qemu.img AddRCscripts

./rootAVD.sh system-images/android-30/android-automotive-playstore/x86_64/ramdisk.img
./rootAVD.sh system-images/android-30/android-automotive-playstore/x86_64/ramdisk.img FAKEBOOTIMG
./rootAVD.sh system-images/android-30/android-automotive-playstore/x86_64/ramdisk.img DEBUG PATCHFSTAB GetUSBHPmodZ
./rootAVD.sh system-images/android-30/android-automotive-playstore/x86_64/ramdisk.img restore
./rootAVD.sh system-images/android-30/android-automotive-playstore/x86_64/ramdisk.img InstallKernelModules
./rootAVD.sh system-images/android-30/android-automotive-playstore/x86_64/ramdisk.img InstallPrebuiltKernelModules
./rootAVD.sh system-images/android-30/android-automotive-playstore/x86_64/ramdisk.img InstallPrebuiltKernelModules GetUSBHPmodZ PATCHFSTAB DEBUG
./rootAVD.sh system-images/android-30/android-automotive-playstore/x86_64/ramdisk.img AddRCscripts

./rootAVD.sh system-images/android-29/android-automotive-playstore/x86/ramdisk.img
./rootAVD.sh system-images/android-29/android-automotive-playstore/x86/ramdisk.img FAKEBOOTIMG
./rootAVD.sh system-images/android-29/android-automotive-playstore/x86/ramdisk.img DEBUG PATCHFSTAB GetUSBHPmodZ
./rootAVD.sh system-images/android-29/android-automotive-playstore/x86/ramdisk.img restore
./rootAVD.sh system-images/android-29/android-automotive-playstore/x86/ramdisk.img InstallKernelModules
./rootAVD.sh system-images/android-29/android-automotive-playstore/x86/ramdisk.img InstallPrebuiltKernelModules
./rootAVD.sh system-images/android-29/android-automotive-playstore/x86/ramdisk.img InstallPrebuiltKernelModules GetUSBHPmodZ PATCHFSTAB DEBUG
./rootAVD.sh system-images/android-29/android-automotive-playstore/x86/ramdisk.img AddRCscripts

Windows

Command Examples:
rootAVD.bat
rootAVD.bat ListAllAVDs
rootAVD.bat InstallApps

rootAVD.bat system-images\android-33\google_apis_playstore\x86_64\ramdisk.img
rootAVD.bat system-images\android-33\google_apis_playstore\x86_64\ramdisk.img FAKEBOOTIMG
rootAVD.bat system-images\android-33\google_apis_playstore\x86_64\ramdisk.img DEBUG PATCHFSTAB GetUSBHPmodZ
rootAVD.bat system-images\android-33\google_apis_playstore\x86_64\ramdisk.img restore
rootAVD.bat system-images\android-33\google_apis_playstore\x86_64\ramdisk.img InstallKernelModules
rootAVD.bat system-images\android-33\google_apis_playstore\x86_64\ramdisk.img InstallPrebuiltKernelModules
rootAVD.bat system-images\android-33\google_apis_playstore\x86_64\ramdisk.img InstallPrebuiltKernelModules GetUSBHPmodZ PATCHFSTAB DEBUG
rootAVD.bat system-images\android-33\google_apis_playstore\x86_64\ramdisk.img AddRCscripts
rootAVD.bat system-images\android-33\google_apis_playstore\x86_64\ramdisk.img toggleRamdisk
rootAVD.bat system-images\android-33\google_apis_playstore\x86_64\ramdisk.img UpdateBusyBoxScript

BLUESTACKS is supported by rootAVD.sh on macOS, not by rootAVD.bat.

Command Examples: for ALL installed AVDs
rootAVD.bat system-images\android-33\google_apis_playstore\x86_64\ramdisk.img
rootAVD.bat system-images\android-33\google_apis_playstore\x86_64\ramdisk.img FAKEBOOTIMG
rootAVD.bat system-images\android-33\google_apis_playstore\x86_64\ramdisk.img DEBUG PATCHFSTAB GetUSBHPmodZ
rootAVD.bat system-images\android-33\google_apis_playstore\x86_64\ramdisk.img restore
rootAVD.bat system-images\android-33\google_apis_playstore\x86_64\ramdisk.img InstallKernelModules
rootAVD.bat system-images\android-33\google_apis_playstore\x86_64\ramdisk.img InstallPrebuiltKernelModules
rootAVD.bat system-images\android-33\google_apis_playstore\x86_64\ramdisk.img InstallPrebuiltKernelModules GetUSBHPmodZ PATCHFSTAB DEBUG
rootAVD.bat system-images\android-33\google_apis_playstore\x86_64\ramdisk.img AddRCscripts
rootAVD.bat system-images\android-33\google_apis_playstore\x86_64\ramdisk.img toggleRamdisk
rootAVD.bat system-images\android-33\google_apis_playstore\x86_64\ramdisk.img UpdateBusyBoxScript

rootAVD.bat system-images\android-25\google_apis_playstore\x86_64\ramdisk.img
rootAVD.bat system-images\android-25\google_apis_playstore\x86_64\ramdisk.img FAKEBOOTIMG
rootAVD.bat system-images\android-25\google_apis_playstore\x86_64\ramdisk.img DEBUG PATCHFSTAB GetUSBHPmodZ
rootAVD.bat system-images\android-25\google_apis_playstore\x86_64\ramdisk.img restore
rootAVD.bat system-images\android-25\google_apis_playstore\x86_64\ramdisk.img InstallKernelModules
rootAVD.bat system-images\android-25\google_apis_playstore\x86_64\ramdisk.img InstallPrebuiltKernelModules
rootAVD.bat system-images\android-25\google_apis_playstore\x86_64\ramdisk.img InstallPrebuiltKernelModules GetUSBHPmodZ PATCHFSTAB DEBUG
rootAVD.bat system-images\android-25\google_apis_playstore\x86_64\ramdisk.img AddRCscripts
rootAVD.bat system-images\android-25\google_apis_playstore\x86_64\ramdisk.img toggleRamdisk
rootAVD.bat system-images\android-25\google_apis_playstore\x86_64\ramdisk.img UpdateBusyBoxScript

rootAVD.bat system-images\android-25\google_apis_playstore\armeabi-v7a\ramdisk.img
rootAVD.bat system-images\android-25\google_apis_playstore\armeabi-v7a\ramdisk.img FAKEBOOTIMG
rootAVD.bat system-images\android-25\google_apis_playstore\armeabi-v7a\ramdisk.img DEBUG PATCHFSTAB GetUSBHPmodZ
rootAVD.bat system-images\android-25\google_apis_playstore\armeabi-v7a\ramdisk.img restore
rootAVD.bat system-images\android-25\google_apis_playstore\armeabi-v7a\ramdisk.img InstallKernelModules
rootAVD.bat system-images\android-25\google_apis_playstore\armeabi-v7a\ramdisk.img InstallPrebuiltKernelModules
rootAVD.bat system-images\android-25\google_apis_playstore\armeabi-v7a\ramdisk.img InstallPrebuiltKernelModules GetUSBHPmodZ PATCHFSTAB DEBUG
rootAVD.bat system-images\android-25\google_apis_playstore\armeabi-v7a\ramdisk.img AddRCscripts
rootAVD.bat system-images\android-25\google_apis_playstore\armeabi-v7a\ramdisk.img toggleRamdisk
rootAVD.bat system-images\android-25\google_apis_playstore\armeabi-v7a\ramdisk.img UpdateBusyBoxScript

Notes

  • 64 Bit Only Systems needs Magisk 23.x
  • In the Menu, you can choose between the newest Magisk, Canary and Stable, Version.
  • With the new Option s, you can see and download any other Versions of Magisk
  • Once choosen, the script will make that Version to your local one.
  • Prebuilt Kernel and Modules will be pulled from AOSP
  • Starting Magisk from Terminal via adb shell monkey -p com.topjohnwu.magisk -c android.intent.category.LAUNCHER 1
  • API 28 (Pie) is not supported at all -> because
  • Magisk Versions >= 26.x can only be proper installed with the FAKEBOOTIMG argument
  • Android 14 and newer need Magisk Version >= 26.x to be rooted
  • This fork has been tested up to API level 37.0 on Google Play Store arm64-v8a
  • API level 36.1 has been tested on Google Play Store arm64-v8a and x86_64
  • Legacy 32-bit images are expected to work, but were not retested

Notes on Magisk Versions

  • Replace the Magisk.zip with the Flavour/Version of your choice
  • Tested Flavours are:

Contributor Workflow

  • rootAVD.sh is now the public loader; implementation modules live in lib/rootavd/.
  • Normal user commands stay unchanged, for example ./rootAVD.sh ListAllAVDs.
  • Run local checks with tools/check.sh; this covers syntax checks, ShellCheck style severity, first-party shfmt formatting, whitespace checks, bundle generation, non-destructive source/bundle smoke, and Bats tests.
  • GitHub Actions runs the same gate from .github/workflows/check.yml.
  • Build a single-file release script with tools/build-rootavd-bundle.sh; output is written to dist/rootAVD.sh.
  • Run non-destructive source/bundle smoke checks with tools/smoke-nondestructive.sh; this also verifies restore and toggleRamdisk against a temporary SDK tree.
  • With one AVD connected, run non-destructive Android shell loader smoke with tools/smoke-adb-load.sh.
  • Keep ordinary modules in lib/rootavd/ free of shellcheck disable comments; only lib/rootavd/bluestacks_loader_template.sh carries generated-template suppressions.
  • lib/rootavd/bluestacks_loader_template.sh is intentionally excluded from shfmt because snapshot tests guard its generated shell text.
  • Magisk.zip can still be replaced locally with the Magisk flavor/version of your choice.

Release Smoke Checklist

See docs/manual-smoke.md for the full release checklist and docs/manual-smoke-results-template.md for the results template. See docs/refactor-status.md for the current automated proof and remaining manual release evidence.

Minimum evidence for this fork's normal AVD workflow:

  • tools/check.sh passes.
  • Source checkout patch flow succeeds on API 37.0 or 36.1 Google Play Store arm64-v8a.
  • The patched AVD cold-boots and Magisk launches.
  • restore makes ramdisk.img byte-identical to ramdisk.img.backup.
  • After a cold boot from the restored ramdisk, adb shell su -c id fails.
  • Repeat the same patch, Magisk launch, restore, and post-restore su check on API 36.1 Google Play Store x86_64 when validating both tested ABIs.
  • Build the generated bundle and repeat one normal patch flow from a bundle-only directory.

Optional/manual feature evidence:

  • PATCHFSTAB: verify the patched ramdisk contains the expected overlay.d/vendor/etc/fstab.ranchu addition.

  • FAKEBOOTIMG: verify the Magisk app can patch /sdcard/Download/fakeboot.img and the script can extract the patched ramdisk.

  • GetUSBHPmodZ, AddRCscripts, kernel-module workflows, BLUESTACKS, and the Windows wrapper should be tested only when those workflows are in scope.

  • Run ./rootAVD.sh ListAllAVDs from a source checkout.

  • Run tools/smoke-nondestructive.sh to compare source and bundle ListAllAVDs output.

  • Run tools/smoke-adb-load.sh to verify source and bundle payload loading through adb shell sh.

  • Run tools/build-rootavd-bundle.sh and dist/rootAVD.sh ListAllAVDs.

  • Push both source-mode payload and generated bundle to an AVD and run sh rootAVD.sh SOURCING DEBUG to verify Android shell loading.

  • Run ./rootAVD.sh InstallApps with no APK files in Apps/ to smoke-test ADB without installing packages.

  • Smoke-test API 37.0 Google Play Store arm64-v8a and API 36.1 Google Play Store x86_64 AVDs before tagging a release.

  • Smoke-test InstallApps, FAKEBOOTIMG, PATCHFSTAB, InstallKernelModules, and InstallPrebuiltKernelModules when the matching local fixtures or online AVD are available.

  • Smoke-test BLUESTACKS and rootAVD.bat on their real target platforms when available.

ANDROID_HOME

  • Default location can be overwritten by setting the ANDROID_HOME variable
  • In both cases, the script will search in it for AVD system-images and adb binarys
  • ANDROID_HOME Sets the path to the SDK installation directory -> AOSP Variables reference

Notes for Microsoft Visual Studio AVDs

  • ANDROID_HOME needs to be set properly i.e. set ANDROID_HOME="C:\Program Files (x86)\Android\android-sdk"
  • "C:\Program Files (x86)\Android\android-sdk" needs elevated write permissions
  • the script will ask for user permissions, every time it needs to write to those locations

Notes for Apk Developers

Fake Boot.img Function

  • During runtime, the script will launch the Magisk APK so that you can patch the fake Boot.img within 60s
  • The script also detects if there is already a patched Boot.img present
  • This feature lets you also update and switch between Magisk Versions
    • Updating a patched ramdisk will delete the overlay.d folder, all mods are gone!
  • If Magisk can't open a file manager, i.e. on Automotive AVDs,
  • The script switches to user 0, so that you can see /sdcard/Download/fakeboot.img

2 Ways to boot the AVD into Safe Mode

  • 1st Way - If the AVD still boots normal:
    • Tap and Hold the Power Button until the 3 Options appear
    • Tap and Hold the Power Off Button until Reboot to safe mode appears
  • 2nd Way - If the AVD stuck while booting (black screen):
    • Tap and Hold the Volume Down Button
    • The Time Window is between the Launching Emulator Bar is approx half way until the Google Boot Screen appears
  • Confirmation
    • On the Bottom Left Corner reads: Safe mode

Android TV Notes

  • An extra File Manager APK is required
  • Due to lack of functionality of the Android TV OS, special permissions are granted during
  • runtime, to all 3rd party installed APKs -> appops set <package_name> MANAGE_EXTERNAL_STORAGE allow
  • the Magisk APK doesn't show up in the Apps location
    • but you can start Magisk from Terminal via adb shell monkey -p com.topjohnwu.magisk -c android.intent.category.LAUNCHER 1

Automotive Notes

  • After patching the ramdisk.img and cycle power, switch to user 0 via adb shell am switch-user 0
    • open the Magisk App and the Requires Additional Setup pops up -> reboot AVD
    • switch again to user 0
      • open the Magisk App -> Settings -> Multiuser Mode -> User-Independent -> reboot AVD
  • Every time you want to Grant Su Permissions, switch to user 0 and then back to 10 adb shell am switch-user 10
  • Alternative, you can install the Module Magisk Single User Mod
    • and remove all user higher than 0 i.e. adb shell pm remove-user 13 or adb shell pm remove-user 10

BlueStacks 4 Notes on MacOs

  • Modules are working
  • Zygisk doesn't work
  • The Home Screen Apk closes as soon as Magisk APP is installed
    • but you can start Magisk from Terminal via adb shell monkey -p com.topjohnwu.magisk -c android.intent.category.LAUNCHER 1
    • and Hide the Magisk APP to Settings i.e.
  • ADB Connection is very buggy, adb kill-server is necessary quite often

Links

XDA [GUIDE] How to [Build|Mod|Update] a custom AVD Kernel and its Modules

How to root AVDs without Play Store (Google APIs) out of the box

Windows

  • open a terminal -> win + r cmd
    • add emulator to your PATH
    • find your AVD
    • launch your AVD with the -writable-system argument
     set PATH=%LOCALAPPDATA%\Android\Sdk\emulator;%PATH%
     emulator -list-avds
     	Pixel_4_API_29
     emulator -avd Pixel_4_API_29 -writable-system
    
  • open a 2nd terminal -> win + r cmd
    • enter the following commands one by one
     set PATH=%LOCALAPPDATA%\Android\Sdk\platform-tools;%PATH%
     adb root
     adb shell avbctl disable-verification
     adb disable-verity
     adb reboot
     adb root
     adb remount
     adb shell
     generic_x86_64:/ #
    

Current fork test status

  • API level 36.1 Google Play Store system images work on arm64-v8a
  • API level 36.1 Google Play Store system images work on x86_64
  • API level 37.0 Google Play Store system images work on arm64-v8a
  • 32-bit x86 and armeabi-v7a images have not been retested in this pass
Archive ### Magisk v23.0 Alpha Successfully tested with Stock Kernel on * [[Oct. 2021] - Android 12 (S) API 32 Google Apis Play Store x86_64 Sv2 r01 Windows Production Build](https://dl.google.com/android/repository/sys-img/google_apis_playstore/x86_64-Sv2_r01-windows.zip) * [[Oct. 2021] - Android 12 (S) API 32 Google Apis Play Store x86_64 Sv2 r01 Darwin/MacOS Production Build](https://dl.google.com/android/repository/sys-img/google_apis_playstore/x86_64-Sv2_r01-darwin.zip) * [[Oct. 2021] - Android 12 (S) API 31 Google Apis Play Store ARM 64 v8a r08 (M1) Darwin/MacOS Production Build](https://dl.google.com/android/repository/sys-img/google_apis_playstore/arm64-v8a-31_r08-darwin.zip) * [[Oct. 2021] - Android 11 (R) API 30 Google Apis Play Store ARM 64 v8a r10 (M1) Darwin/MacOS Production Build](https://dl.google.com/android/repository/sys-img/google_apis_playstore/arm64-v8a-30_r10-darwin.zip) * [[Oct. 2021] - Android 12 (S) API 31 Google Apis Play Store x86_64 r08 Darwin/MacOS Production Build](https://dl.google.com/android/repository/sys-img/google_apis_playstore/x86_64-31_r08-darwin.zip) * [[Oct. 2021] - Android 11 (R) API 30 Google Apis Play Store x86 r09 Darwin/MacOS Production Build](https://dl.google.com/android/repository/sys-img/google_apis_playstore/x86-30_r09-darwin.zip) * [[Oct. 2021] - Android 11 (R) API 30 Google Apis Play Store x86_64 r10 Darwin/MacOS Production Build](https://dl.google.com/android/repository/sys-img/google_apis_playstore/x86_64-30_r10-darwin.zip)

Magisk v22.1+ Successfully tested with Stock Kernel on

Change Logs

[Oct 2024]

  • [rootAVD.sh] - Added Support for LD_PRELOAD of init
  • [General] - Updated to Magisk v26.4
  • [rootAVD.sh] - Removed Magisk Alpha as it moved to App Center and TG

[March 2024]

  • [rootAVD.sh] - Added MANAGE_EXTERNAL_STORAGE allow
  • [rootAVD.sh] - Added PREINITDEVICE config
  • [rootAVD.bat] - Added support for elevated write permissions
Archive

Change Logs

[December 2023]

  • [rootAVD.sh] - Fixed GetUSBHPmod Download Links and typos

[November 2023]

  • [rootAVD.bat] - Fixed another space issue

[October 2023]

  • [General] - Moved to GitLab

[August 2023]

  • [rootAVD.sh] - Added Pagesize Padding in the fakeboot.img
  • [rootAVD.sh] - Updated the creation of the fakeboot.img
  • [rootAVD.sh] - Added another way of checking the AVDs Internet connection

[July 2023]

  • [rootAVD.bat] - Fixed file ListAllAVDs not found bug
  • [rootAVD.bat] - Fixed some errors with double spaces
  • [rootAVD.bat] - Added TestADBWORKDIR routine

[June 2023]

  • [rootAVD.sh] - improved finding BusyBox routine, and once again
  • [rootAVD.sh] - rewritten the file and folder handling entirely, Darwin and Linux
  • [rootAVD.sh] - improved finding BusyBox routine, again
  • [General] - Added .gitattributes with *.sh text eol=lf to force UNIX line ending on Windows
  • [rootAVD.bat] - rewritten the file and folder handling entirely
  • [rootAVD.bat] - fixed typos and bug fixes
  • [rootAVD.bat] - updated the TestADB routine, adb path will now be set automatically
  • [rootAVD.bat] - updated Exit calls
  • [General] - updated the README.md

[May 2023]

  • [rootAVD.sh] - removed Busybox from Script

[April 2023]

  • [General] - added link to X-plore file manager
  • [General] - added link to Magisk Single User Mod
  • [General] - added switching to user 0 when running FAKEBOOTIMG
  • [rootAVD.bat] - changed return 1 to return 0
  • [rootAVD.sh] - changed return 1 to return 0
  • [rootAVD.sh] - changed copy and move routine
  • [rootAVD.sh] - added support for ramdisk-qemu.img

[December 2022]

  • [rootAVD.sh] - Fixed arithmetic syntax error in decompress_ramdisk

[November 2022]

  • [General] - Bug fixes
  • [General] - Updated to Magisk Stable Version 25.2
  • [General] - Added FAKEBOOTIMG Use Case Examples as Gif
  • [rootAVD.sh] - Added support for adding the stub.apk if present
  • [General] - Added support for already patched ramdisk files
  • [General] - removed the EnvFixTask Argument
  • [General] - Bug fixes
  • [rootAVD.sh] - Added FAKEBOOTIMG Argument that creates a fake Boot.img which can be patched directed from the Magisk APK

[March 2022]

  • [rootAVD.sh] - Added toggleRamdisk Argument that toggles between patched and stock ramdisk
  • [rootAVD.sh] - Changed the need of a Magisk.zip file
  • [General] - Added Use Case Examples as Gif
  • [General] - Added Option to Download older Magisk Versions
  • [rootAVD.sh] - Added BlueStacks 4 Support on MacOS
  • [General] - Bug fixes

[February 2022]

  • [General] - Updated to Magisk Stable Version 24.1

[October 2021]

  • [rootAVD.sh] - Added get Up-To-Date Script Routine if Script is broken
  • [rootAVD.sh] - Updated LZ4 decompression Routine
  • [rootAVD.sh] - Updated InstallPrebuiltKernelModules Routine to support ARM64 Kernels
  • [rootAVD.sh] - Updated Busybox Extraction Routine
  • [General] - Added Multiarch Busybox Binarys and 64-Bit Only Support
  • [General] - Added Alpha Channel to the Menu
  • [rootAVD.bat] - Added Shut Down Feature
  • [rootAVD.sh] - Added Shut Down Feature
  • [General] - Added Android 12 (S) API 31 Status
  • [General] - Added Link to Android AppSecs Video about rootAVD

[July 2021]

  • [rootAVD.bat] - Changed TestADB
  • [General] - Added rootCROS Project to Links

[June 2021]

  • [General] - Android 12 (S) r05

[May 2021]

  • [General] - Updated to Magisk App v23.0
  • [rootAVD.sh] - Added "AddRCscripts" Argument that *install all custom .rc scripts, placed in the rootAVD folder, into ramdisk.img/overlay.d/sbin
  • [rootAVD.sh] - Added BusyBox Binary after the rootAVD script
  • [rootAVD.bat] - Added ListAllAVDs and InstallApps as Arguments
  • [rootAVD.sh] - Added "ListAllAVDs" Argument that Lists Command Examples for ALL installed AVDs
  • [rootAVD.sh] - Added "InstallApps" Argument to Just install all APKs placed in the Apps folder
  • [rootAVD.bat] - Added comprehensive Help Menu

[Apr. 2021]

  • [General] - Added comprehensive Help Menu
  • [rootAVD.sh] - Changed "DEBUG" "PATCHFSTAB" "GetUSBHPmodZ" to Arguments
  • [General] - Fixed some typos and functions
  • [rootAVD.sh] - Add a Menu to choose the prebuilt Kernel and Modules Version to install
  • [General] - Added "InstallPrebuiltKernelModules" download/update/install prebuilt kernel and modules
  • [General] - Added 2 Ways to boot the AVD into Safe Mode
  • [rootAVD.sh] - Added Android S rev 3 support
  • [General] - Added "InstallKernelModules" update/install custom build kernel and modules
  • [rootAVD.sh] - Added update_lib_modules function
  • [General] - Added "restore" to put back your backup files
  • [General] - Updated local Magisk App v22.1
  • [rootAVD.sh] - Added Option to Download the USB HOST Permissions Module

[Mar. 2021]

  • [General] - Add a Download Manager Function for bad TLS record using wget
  • [rootAVD.bat] - Adjustments to run with the updated rootAVD.sh
  • [General] - Add a Menu to choose the Magisk Version to install
  • [rootAVD.sh] - Added EnvFixTask Argument to fix Requires Additional Setup in Android S
  • [General] - Changed to BusyBox (D)ASH Standalone
  • [General] - Re-Structured Script
  • [rootAVD.sh] - Added "Additional Setup Required" manually for Android S
  • [rootAVD.sh] - Updated shakalaca's Ramdisk Repack Routine
  • [rootAVD.sh] - Added Compression Detection for LZ4 and GZ
  • [General] - Fixed some bugs and typos
  • [General] - Updated to Magisk App v22.0

Magisk v21.4 Successfully tested with Stock Kernel on

Credits

About

Script to root AVDs running with QEMU Emulator from Android Studio

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages