How to make magisk module in just 3 steps

There was a time when we used to flash supersu in order to root our devices but now Google has improved android’s security by implementing an API called safteynet in google play services. The reason to implement this API is to detect root on your device or whether you are running a custom rom or not and stop apps working on your device, basically, google is forcing you to use a clean non-rooted secure device instead of rooting it and installing a custom rom. If sayteyNet fails on your device a majority of apps like google pay, Netflix, Spotify and bank apps will not work on your device. This gives rise to “Magisk” a root binary that installs systemlessly. Systemlessly means it installs the root binary without touching the system. Magisk is not only a root binary but also allows you to modify your device by installing a magisk module. In this article, we will learn how to make magisk modules.

Before we proceed to make magisk modules we must know how magisk modules work in order to fix bugs generated by magisk incompatibility. The main purpose of magisk is to install root binary without getting detected by safteynet API. Magisk also provides an app called magisk manager in which a user can manage root access and install or uninstall magisk modules.
Magisk uses a mode called systemless mode to install root binary and its modules. In this systemless mode, the system partition is untouched. Magisk uses the kernel partition as working partition means it injects its root binary and module loader scripts directly into the kernel and uses the kernel partition to store its modules.
A module can be an app or a script. The modules get applied on the fly when you boot your device. A module can be used to replace an app without actually replacing means the original app remains in the system partition but instead of it the module’s app gets loaded overriding the original app.

How to make magisk module

Requirements

Notepad++
Magisk module template
Winrar

Procedure to make a magisk module.

Step 1. Preparing the files

At first, make one folder named magisk on the desktop. Download the magisk module template from here and extract it on the “magisk” folder you created on the desktop.
Now copy the files you want to include in the module (e.g, apps or scripts. In the article I will show how to make an app module for magisk) to the “magisk” folder.

Step 2. Editing the files.

Open the readme.md file using notepad++, This file is used to display description, requirements or additional steps to install your magisk module. Readme.md file is only used in magisk manager, so if you plan to upload your module to magisk modules repository then editing readme.md file is required otherwise you can leave it as it is.
Now open module.prop using notepad++, this file is used to show version, id, name etc. it is described below.

 

 

Module.prop
Id= it is used to display the id
name= This is the name that will appear in the install screen
version= this is the version no.
versionCode= This is the version code, it can be same as version no.
author= you name will be here
description=A short description about the module
minMagisk=1500 (it is used to specify minimum magisk version required by your mod)

Now its turn for config.sh, open it using notepad++. This file is important if your module will replace any app or your module is permission sensitive. This file is described below.

# Configs
##########################################################################################

# Set to true if you need to enable Magic Mount
# Most mods would like it to be enabled
AUTOMOUNT=true

# Set to true if you need to load system.prop
PROPFILE=false

# Set to true if you need post-fs-data script
POSTFSDATA=false

# Set to true if you need late_start service script
LATESTARTSERVICE=false

Automount= set this to true, it enables magic mount to automatically mount the system or data drive while installing the module.

PROPFILE= if it is set to true then the module will load system.prop script stored in common folder. It is useful if you want to change system settings like screen density after installing the module.

POSTFSDATA= set this to true if you want your module to load post-fs-data.sh from the common folder and execute post-fs-data mode.

LATESTARTSERVICE= set it to false most modules don’t need it.

# Installation Message
##########################################################################################

# Set what you want to show when installing your mod

print_modname() {
ui_print "*******************************"
ui_print " Magisk Module Template "
ui_print "*******************************"
}

You can edit the “#installation message” section if you want to show your name or your module’s name while installing the module. An example of how to edit is shown below.

Also see: How to clone apps on android

# Installation Message
##########################################################################################

# Set what you want to show when installing your mod

print_modname() {
ui_print "*******************************"
ui_print " Your module’s name "
ui_print "by your name"
ui_print "*******************************"
}

description and replace list

# Replace list
##########################################################################################

# List all directories you want to directly replace in the system
# Check the documentations for more info about how Magic Mount works, and why you need this

# This is an example
REPLACE="
/system/app/Youtube
/system/priv-app/SystemUI
/system/priv-app/Settings
/system/framework
"

Replace list is used to replace an app with your app. For example, if you want to replace the youtube app with your modded app the code will be-

REPlACE=” /system/app/Youtube”

#Permissions

I have not written about permission in detail because most external scripts or apps do not need extra permission so it will work with the default specified permission.

#Custom functions

This feature is used by magisk to keep update-binary as free as possible because it can cause problem while updating your module. So all the custom functions are written in the config.sh file.

Step 3. Placing the files and packing the module.

Now after everything is done place your app in system/priv-app or system/app folder. At last, make a zip of everything inside the folder and rename it and flash it happily.

If you have any problem while making magisk module then don’t feel shy to post them in comments.

Get more stuff like this

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

1 thought on “How to make magisk module in just 3 steps

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.