val rootBeer = RootBeer(context)
if (rootBeer.isRooted) {
//we found indication of root
} else {
//we didn't find indication of root
}
You can also call each of the checks individually as the sample app does. It is advisable to call isRooted()
from a background thread as it involves disk I/O.
Manufacturers often leave the busybox binary in production builds and this doesn't always mean that a device is root. We have removed the busybox check we used to include as standard in the isRooted() method to avoid these false positives.
If you want to detect the busybox binary in your app you can use checkForBinary(BINARY_BUSYBOX)
to detect it alone, or as part of the complete root detection method:
rootBeer.isRootedWithBusyBoxCheck();
The following devices are known the have the busybox binary present on the stock rom:
- All OnePlus Devices
- Moto E
- OPPO R9m (ColorOS 3.0,Android 5.1,Android security patch January 5, 2018 )
Available on maven central, to include using Gradle just add the following:
dependencies {
implementation 'io.github.usefulness:rootbeer-core:{{ version }}'
}
- Kevin Kowalewski and others from this popular StackOverflow post
- Eric Gruber's - Android Root Detection Techniques article
If you dig this, you might like:
- Tim Strazzere's Anti emulator checks project
- Scott Alexander-Bown's SafetyNet Helper library - coupled with server side validation this is one of the best root detection approaches. See the Google SafetyNet helper docs.