Effective Way to Detect Whether an Android Device is Rooted Using MAUI

Manjunath Vadigeri 0 Reputation points
2025-01-28T12:10:18.3833333+00:00

I’m currently working on a MAUI-based application and need an effective way to detect whether an Android device is rooted. I’ve tried a couple of approaches, but none seem to work reliably. Here’s what I’ve attempted so far:

1. Simple Approach Using su Command

I started with a straightforward method to check for root access by executing the su command:

bool isRooted = Java.Lang.Runtime.GetRuntime().Exec("su").ExitValue() == 0;

However, this approach fails to detect root access. Interestingly, running su via adb shell on the same device successfully grants superuser access ($ changes to #), but the above code doesn’t work as expected.

2. Using a NuGet Package

Next, I tried using a NuGet package called banditoth.MAUI.JailbreakDetector:

This package checks for:

  • Presence of superuser executables (e.g., su).
  • Known rooting apps installed on the device.
  • Write permissions in restricted directories.

Unfortunately, this solution also fails to detect root access on my test device.

Request for Suggestions

I’m looking for a reliable and effective way to detect root access on Android devices using the .NET MAUI framework. If anyone has successfully implemented root detection in a MAUI app, I’d appreciate any guidance or code examples.

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,904 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 71,101 Reputation points
    2025-01-28T19:25:55.5666667+00:00

    you should see this thread (your approach can lead to zombie processes):

    https://stackoverflow.com/questions/1101380/determine-if-running-on-a-rooted-device

    the consensus is to use google play api:

    https://developer.android.com/google/play/integrity/overview

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.