How to Detect Root using Kotlin

Need to secure your app against rooted devices? Start here.

As a developer facing the challenge of root detection, you’ve landed exactly where you need to be—we’ll break down your options and help you make the right choice. Written by experts who’ve built and battled this themselves 😎.

What is rooting?

Rooting is the process of gaining privileged (root or superuser) access to an Android device. Rooting bypasses the application sandbox model, allowing users—and attackers—to access and modify system-level files and settings.

Think of rooting as “administrator access” on a Linux-based OS (which Android is). Common rooting tools include Magisk, SuperSU, Shamiko, KingoRoot and much more.

And how common is root access? 0.03% of devices are rooted — a significant number that could pose security risks

Number of Rooted Devices (source: Talsec)

While rooting can enable customizations (e.g. removing bloatware, customizing ROMs, running system-level scripts), with that power comes a huge attack surface. It introduces security vulnerabilities—like the ability to hook and inject the code using tools like Frida or Xposed.

How to detect rooted device?

Detecting root on Android is complex and constantly evolving, especially with tools like Magisk. While building your own solution offers control, it’s not recommended due to the time, effort, and expertise required to keep up. Instead, using third-party libraries like freeRASP or RootBeer provides a reliable and up-to-date solution maintained by experts.

Let's compare the most popular options. It's immediately clear why freeRASP is so popular—with a staggering 6,000+ apps using it as of July 2025.

  1. 👑 freeRASP (free library by Talsec)

// Start detection (asynchronously)
Talsec.start(...)

override fun onRootDetected() {
    Log.w("freeRASP", "Device is rooted!")
    // Take action if needed
}
  1. 🍺 RootBeer (open-source library by Scott Alexander-Bown)

  • Open-source root detection tool.

  • Fully offline checks (no internet dependency).

  • Lacks detection of the latest techniques.

  • Used by 5000+ apps

// Perform detections (blocking)
val rootBeer = RootBeer(...)

if (rootBeer.isRooted) {
    Log.w("RootBeer", "Device is rooted!")
    // Take action if needed
}
  1. 📡 Play Integrity (library by Google)

Comparison Table

Capability
freeRASP
RootBeer
Play Integrity API

Root Detection Accuracy

High

Medium

❌ Indirect (via signals)

Trusted by

6000+ apps

5000+ apps

N/A

Works Offline

❌ (requires Google Play + Backend)

Detection Response

Listener-based

Manual check

Backend-dependent, server-based validation

Covers Magisk/Hidden Root

❌ (Indirect)

Easy Integration

Moderate (needs server)

Additional Threats Detected

Emulator, Tamper, Debug, Install Source

Root only

Account

Community & Support

Active

Declining

Classic Google — no support whatsoever.

Integration

In-app SDK

In-app SDK

In-app SDK + Backend-dependent, Google-only

You can find detailed description about root and jailbreak detection in our glossary and articles:

Cover

Glossary: Root Detection

Cover

Glossary: Jailbreak Detection

Last updated

Was this helpful?