Magisk includes built-in bootloop protection: if your device fails to finish booting (boot_completed) twice in a row, Magisk will automatically enter Safe Mode on the next boot, disabling all modules (by creating a disable file in each module folder) and disabling Zygisk so your device can boot normally.
If your device is stuck before automatic bootloop detection can recover it, or you want to manually recover:
adb devices), enter ADB shell and run the command magisk --remove-modules. This will remove all your modules and automatically reboot the device.If you do not have USB debugging enabled and the device cannot boot, you can trigger Safe Mode manually using the hardware key combo at boot. Most modern Android devices support a special key combo at boot to enter system Safe Mode as an emergency option, but please note that Magisk’s key combo detection occurs earlier than system detection so the key combo timing indicated by many online guides may need to be altered to activate Magisk’s Safe Mode. (It’s possible to activate system Safe Mode but not Magisk Safe Mode and vice versa.)
The following details should ensure that modules are properly disabled:
Magisk no longer handles root hiding. There are plenty of Magisk/Zygisk modules available that specifically provide these functionalities, please search around 😉
With the emulator running and accessible via ADB, run ./build.py emulator [path to Magisk APK] (or ./build.py emulator -b to build and install from source) to temporarily start Magisk on the running emulator. This runtime setup is not persistent across cold reboots, so re-execute the command to emulate a reboot if required.
For a persistent installation on an Android Virtual Device (AVD), you can patch its ramdisk.img directly on your host machine using ./build.py patch --avd <path/to/ramdisk.img> [output].
These commands are tested on the official Android Virtual Device (AVD) shipped alongside Android Studio; other emulators may work, but the emulator must have SELinux enabled.