Root an Emulator or Android Virtual Device(AVD)

Getting Started

rootAVD offers a set of handy scripts with Magisk to root an emulator within no time.

To download, follow rootAVD repo OR clone using below command in Terminal (Mac) or Command Prompt (Windows)

~ % git clone https://github.com/newbit1/rootAVD.git

Alternatively, same repo is hosted on GitLab -> rootAVD. No change is steps to root device.

Once cloned, change dir using below cmd

~ % cd rootAVD

Next up, run ./rootAVD.sh to start rootAVD agent:

rootAVD % ./rootAVD.sh
Output in Terminal after running git clone, cd and command to start rootAVD agent.
Output after cloning, cd, and starting rootAVD Agent

At this point, rootAVD agent is active. Now, before running another set of commands, ensure Emulator is running and not rooted.

I’m using Pixel 6a, API 29 for this demo. To verify root status, run adb shell in Android Studio terminal:

% adb shell
generic_x86:/ $

Now, run su for super user access:

generic_x86:/ $ su
/system/bin/sh: su: inaccessible or not found

Since, su is not accessible we can confirm device is NOT rooted.

Back to the rootAVD agent in terminal, run ./rootAVD.sh ListAllAVDs to list all the available emulators.

Screenshot of terminal showing list of available AVD/Emulator to patch for Root access.
List of available AVDs

Select and copy cmd having ramdisk.img of running emulator/AVD

Now, run the cmd to start patching emulator with root privilege

rootAVD % ./rootAVD.sh system-images/android-29/google_apis_playstore/x86/ramdisk.img
*** Moment of truth *** 🤞

At a point, it will prompt to select Magisk channel — Stable, Canary or Alpha. Wait to auto proceed with Stable version of the Magisk.

Prompt in terminal to select channel of Magisk.
Selection prompt in terminal

Once the patching finishes, Emulator will shut down automatically.

Root success

Yayyy!! Emulator is now patched with ROOT access 🎉

Boot the same emulator to verify Magisk App & ROOT status in terminal of Android Studio

Leave a Reply