Tutorial How to root AVD (Android Virtual Device) with Magisk

AndnixSH

PMT Elite Modder
Staff member
Modding-Team
It is possible to root AVD (Android Virtual Device) with Magisk using rootAVD script. It works on Windows/Mac/Linux

Requirements:
- Android Studio. See tutorial how to install it: Install Android Studio | Android Developers
- Have at least one AVD created and running with boot option set to "Cold boot". See tutorial how to set it up: Create and manage virtual devices | Android Studio | Android Developers
- A working Internet connection for the Menu
- Be able to use terminal/cmd
- rootAVD script (Direct link): https://gitlab.com/newbit/rootAVD/-/archive/master/rootAVD-master.zip
- Have ANDROID_HOME enviornment path set of your SDK path. Check the documentation for your operation system to learn how. Reference: Environment variables | Android Studio | Android Developers

1701336035866.png


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
If you have not open your project, a “Welcome to Android Studio” dialog will be shown. You can open AVD from the menu (3 dots) and click Virtual Device Manager

2024-03-04 11 57 13.png


If you have opened your project, you can open AVD from Tools > Device Manager

1709565918766.png


Ensure that your target instance you want it to be rooted, have boot options is set to Cold boot to ensure stability. Stop the instance first then 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
- newbit / rootAVD · GitLab
- Environment variables | Android Studio | Android Developers
- GitHub - topjohnwu/Magisk: The Magic Mask for Android
 
Last edited:
What Android version and Magisk version is it? Can you double check using AIDA64 app to ensure the emulator is an arm64 image? Last time I tried it works on Android 13 straight forward
I used the same emulator device android 13 as u, i tested both magisk 25.2 and 26 on pixel 2.
I will try that aida64 app but like i said zygisk mod cant run with arm64 and i ran other mods so kinda confused
 
Without explanation today it says I can't dlopen libicu
but the mod somehow works ,, do u know anything about the dlopen error(s) and what it means/how to fix?


Screenshot 2023-12-23 at 10.07.18 AM.png
 
Without explanation today it says I can't dlopen libicu
but the mod somehow works ,, do u know anything about the dlopen error(s) and what it means/how to fix?


View attachment 586417
I don't know about the error. But Magisk does not officially support AVD, and AVD does have some bugs, so except some errors
As long as the mod works, just ignore the errors.
 
Going to save this for later. I struggled trying to get root on avd months ago. Had to just give up on it
There are a few inaccuracies on the guide and some things that aren't very clear or missing.
The most important is when creating an instance is to make sure cold boot is selected so the instance always cold boot.
One quick boot and all ur data gone emulator corrupted
Also important to select the fakeboot option for magisk 26
 
There are a few inaccuracies on the guide and some things that aren't very clear or missing.
The most important is when creating an instance is to make sure cold boot is selected so the instance always cold boot.
One quick boot and all ur data gone emulator corrupted
Also important to select the fakeboot option for magisk 26
That may explained why my instance broke but I totally forgot about safe mode, I just deleted the instance

Also important to select the fakeboot option for magisk 26
Already mentioned:
 
Have you had any success trying to pass saftynet with Android Studio + rootAVD + Magisk?


As default Magisk will keep in 25. Is Magisk 26 required to pass saftynet?


A few apps wont appear on Google Play due to this.
 
So we can forget about installing those apps that are not appearing in Google Play Store with AVD?

I was going to ask you if you managed, but if it is due to a certificate of AVD then it is not possible.


I wanted to get a Apple Mac M1 machine as they have ARM processors and virtualization.

The reason for getting this device was because some apps fail on Android emulators due to x86 frameworks and translation.

Do you have any alternatives/emulators/ WSA that may work to run ARM APKs on desktop devices?
 
So we can forget about installing those apps that are not appearing in Google Play Store with AVD?

I was going to ask you if you managed, but if it is due to a certificate of AVD then it is not possible.


I wanted to get a Apple Mac M1 machine as they have ARM processors and virtualization.

The reason for getting this device was because some apps fail on Android emulators due to x86 frameworks and translation.

Do you have any alternatives/emulators/ WSA that may work to run ARM APKs on desktop devices?
Hiding google services does make some apps appear, at least on my rooted phone

Here is all list of x86 emulators.

Here is all list of ARM emulators.
 
Thank you so much AndnixSH!

I gave a look at it and never though abour running an ARM version on a cloud based Emulator.

Also knew about the Windows ARM versions. All work with Qualcomm processors. As per my research none of them will allow virtualization, meaning that they wont run any Emulator due to not being able to activate Hyper-V.

I was thinking about purchasing a Microsoft SQ2 + 16GB and installing GApps+ Magisk. But not sure if I will be capable of hiding root + passing saftynet. Main issue I am getting, is beeing able to find applications on Google Play Store. I tried hiding root many times, including from Google Services.

I have been told that the reason for this is Saftynet.

Big props to you! What an amazinng work you have around here.


Thank you
 
Thank you so much AndnixSH!

I gave a look at it and never though abour running an ARM version on a cloud based Emulator.

Also knew about the Windows ARM versions. All work with Qualcomm processors. As per my research none of them will allow virtualization, meaning that they wont run any Emulator due to not being able to activate Hyper-V.

I was thinking about purchasing a Microsoft SQ2 + 16GB and installing GApps+ Magisk. But not sure if I will be capable of hiding root + passing saftynet. Main issue I am getting, is beeing able to find applications on Google Play Store. I tried hiding root many times, including from Google Services.

I have been told that the reason for this is Saftynet.

Big props to you! What an amazinng work you have around here.


Thank you
Do you mind telling me the specific apps that are hidden from rooted enviornment? I can try searching for them on my rooted phone

Also, forget about Safetynet, it is dead. Play Integrity is the current protection now
 
This app per my research has a ARM layer or detection. Therefore it wont run on conventional emulators.

The ultimate goal would be to have access from my laptop to any app as I have all my work there.

 
This app per my research has a ARM layer or detection. Therefore it wont run on conventional emulators.

The ultimate goal would be to have access from my laptop to any app as I have all my work there.

I'm actually using Revolut on my rooted phone. It still work perfectly and still shown on Play store

It's also shown on MuMu 12 emulator but apps crashes. Looking through the logs, it was caused by protection/obfuscation (com.revolut.ProtectedRevolutApplication)
 

Attachments

  • Screenshot_20240229-104049.png
    Screenshot_20240229-104049.png
    160.3 KB · Views: 73
  • Screenshot_20240229-104032.png
    Screenshot_20240229-104032.png
    191.6 KB · Views: 75
I'm actually using Revolut on my rooted phone. It still work perfectly and still shown on Play store

It's also shown on MuMu 12 emulator but apps crashes. Looking through the logs, it was caused by protection/obfuscation (com.revolut.ProtectedRevolutApplication)


Hello,

I also was able to open the app on my rooted phone device. Also performs great.

The issue to open it on any desktop/laptop device. I think the issue is due to Safetynet + ARM.

Btw, did you install the app through Google Play Store in your Mumu Emulator or downloaded it outsource?

What do your think can be the fix?
 
Hello,

I also was able to open the app on my rooted phone device. Also performs great.

The issue to open it on any desktop/laptop device. I think the issue is due to Safetynet + ARM.

Btw, did you install the app through Google Play Store in your Mumu Emulator or downloaded it outsource?

What do your think can be the fix?
Yes, I did. Idk how to fix the issue. The only way is to feedback to the emulator developers

ARM apps are generally supported on emulators, but due to APK protection and obfuscation, it breaks compatibility. A bypass is needed, provided emulator developers, just like how they bypassed Clash of clans fake crash.

I can't even disassemble the APK in Jadx. It definitely has strong protection 🤣
 
Back
Top Bottom