How to root AVD (Android Virtual Device) with Magisk

It is possible to root AVD (Android Virtual Device) with Magisk using rootAVD script. It works on Windows/Mac/Linux

Requirements:

Note:

You can’t use ARM images on x86 computer or vice versa.

ARM only zygisk modules will not work on x86 AVD. Because Zygisk injects zygote, ARM translation can’t be supported, it is by design. Currently only x86 supported modules will work on x86 systems, and only ARM supported modules will work on ARM systems. If you really want to run ARM based AVD, buy a computer with ARM processor (e.g Macbook with silicon processor)

Additional notes taken from newbit:

  • 64 Bit Only Systems needs Magisk 23.x
  • In the Menu, you can choose between the newest Magisk, Canary, Stable and Alpha, 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 needs Magisk Version >= 26.x to be rooted

Rooting AVD

Ensure that your target instance you want it to be rooted, have boot options is set to Cold boot to ensure stability. Edit the instance by
clicking on 3 dots > Edit

1703418955499.png

Click Show Advanced Settings and choose "Cold boot"

1703418841795.png

Run the instance

Once you have downloaded rootAVD, extract it to your desired location

Open Terminal/Powershell/CMD from the location of rootAVD

2023-11-29 16 45 09.png

type the following

Code:

./rootAVD ListAllAVDs

and hit enter to list all installed AVDs

1701276093525.png

In this case, my target is Android 13 image with Play Store, so I will use one of these commands

Code:

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

For now, we will only use this command to root it. We would type “./”, copy the first line of command from the terminal and paste it in the terminal and add “s” at the end

Code:

./rootAVD.bat system-images\android-33\google_apis_playstore\x86_64\ramdisk.img s

1701276570711.png

then hit enter

When asked, choose what version of Magisk you want it installed by typing the number

1701276660998.png

Once choosen, the script will continue and will make that version to be installed

Wait and do not touch anything until the process is completed. If the AVD doesnt shut down, do it manually!

Start the AVD again, if it won’t boot, try cold boot by clicking on 3 dots > Cold Boot Now

1701290032546.png

You will now see Magisk app on the app drawer. Open it. If it prompt about additional setup, just click OK

1701276588304.png

The root is completed!

1701278537407.png

Updating Magisk

You can’t update Magisk directly from the app. Instead, you need to re-run the rootAVD script again. Just this command line will do the job

Code:

./rootAVD.bat system-images\android-33\google_apis_playstore\x86_64\ramdisk.img s

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 (blackscreen):
    • 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

BONUS

If you are using an ARM computer (Mac, Raspberry Pi, etc), you can use ARM images instead x86 images so you can use ARM only modules like ImGUI zygisk module. NO x86 involved. I’m lucky to own a Mac mini M1 (2020) with silcone processor and I was able to use ImGUI by @Yunana24 perfectly

1701333651725.png

References

Comments

Popular Posts

VMOS Pro Global CN FREE Custom ROMs | Gapps, ROOT, Xposed | Android 4.4.4, 5.1.1, 7.1.2, 9.0 ROMs | NO VIP

How to activate VMOS Assistant to run VMOS on Android 12 and above