What is Riru, and what can you do with it on your Android device?

Not sure what is Riru and how to use it? We explain everything that you need to know about this unique Magisk module.

An image made from including the Android Bugdroid mascot, the Xposed Module icon, and the Magisk Manager icon, to talk about what Riru is

 

Before Magisk became a thing, it was Xposed Framework that popularized the device-agnostic Android modding approach. Instead of resorting to the hard way, i.e. decompiling the target application, modifying the bits and pieces, recompiling everything, and pushing the modded file back to our devices, we could replace any method in any class at runtime using Xposed and a purpose-built module. The framework is essentially a modification of /system/bin/app_process to load additional JAR files on startup, which allows developers to hook into the Zygote process and can act in its context.

Since Magisk offers an overlay-based modding mechanism (often referred to as “systemless”), one can theoretically create a Magisk module to tinker with the Zygote process without physically modifying the app_process executable. This is where Riru comes in.

What is Riru?

Created by two developers named Rikka and yujincheng08, Riru is a specially crafted Magisk module that offers Xposed-esque functionalities without the need of installing the old-school Xposed Framework. It injects into Zygote in order to allow other modules to run their codes in apps or the system server.

How does Riru work?

The initial implementation of Riru relied on the replacement of a particular system library called libmemtrack. However, the method was later abandoned in favor of a system property known as the “native bridge” (ro.dalvik.vm.native.bridge). By exploiting the property, the developers can dynamically load and unload shared libraries of their choice, which ultimately leads to injecting into the Zygote process.

How to download and install Riru?

As mentioned earlier, Riru is available as a Magisk module. Due to the fact that the Magisk app no longer comes with a built-in module browser, you need to download Riru straight from its GitHub repository.

Download Riru

After downloading the release ZIP file, you can install it using the Magisk app.

  1. If you’ve downloaded the package on a PC or a Mac, then connect your Android device to it and copy the downloaded ZIP file to the internal memory of the target device.
  2. Open the Magisk app on your phone and switch to the Modules tab using the bottom navigation menu.
  3. Tap on the button named Install from storage.
  4. Browse and select the module ZIP you downloaded earlier.
  5. Magisk will now install the module and prompt you to restart.

If everything goes right, you can see Riru listed under the Modules tab of the Magisk app after rebooting.

What can I do with Riru?

Riru itself is just a doorway for other modules to hook into the Zygote process. As such, you need to install Riru-compatible modules via the Magisk app, just like any other Magisk modules. However, some modules might not be compatible with the latest Riru release. Hence, you must determine the version dependency of the module and install the suitable build of Riru before flashing the modules.

After a successful installation, Riru modules will be listed alongside Magisk modules in the Magisk app. You can then open the module-specific configuration front-end to modify its parameters. For the modules that have no interface, you can simply continue using your modded Android instance and Riru will take care of everything in the background.

Riru with another module
Keep in mind that a handful of stock as well as custom ROMs are incompatible with Riru out of the box due to a particular SELinux rule implementation. There is no easy way to resolve the issue other than altering the source of the ROM, so it’s better to stick with a known compatible Android distribution such as LineageOS.

What is the difference between Riru and Zygisk?

On any recent version of Magisk, you may face a situation where Riru is disabled after installation due to the presence of Zygisk.

Riru suspended for Zygisk

The reason behind this conflict is rather simple, though. Zygisk (e.g. Magisk in Zygote) is the spiritual successor to Riru. It’s the evolution of the systemless interface that XDA Senior Recognized Developer topjohnwu (i.e. the creator of Magisk) and several other developers have been working on for a while. As both Riru and Zygisk target the Android Zygote process, these two can’t exist simultaneously in their default configurations. However, you can disable Zygisk from Magisk’s setting, reboot the device, and then enable Riru.

As a matter of fact, the maintainers of Riru practically stopped developing the project a while ago. They suggested module developers switch to Zygisk in the future. With that said, Zygisk is still in a nascent stage and there is a lot of scope for improvement, hence the migration will take time. Meanwhile, you can continue to use Riru and its modules.

If you’re interested in more Android modding guides, why not read our tutorials on how to install a custom ROM on your Android phone, how to back up and restore data on Android, and how to pass SafetyNet on Android after rooting.