/

Quick Start - Monitor for Android

Get ByteHide Monitor protecting your Android application in under 5 minutes using the Gradle plugin. No code changes required for basic protection.


Prerequisites

  • Android Studio with Gradle support (AGP 7.0+ or 8.0+)
  • Java 11 or higher
  • A ByteHide account with a Monitor project (create one here)
  • Your ByteHide Project Token from app.bytehide.com

Step 1: Configure Repositories

Add Maven Central to your settings.gradle.kts:

Kotlin
// settings.gradle.kts
pluginManagement {
    repositories {
        mavenCentral()
        gradlePluginPortal()
        google()
    }
}

dependencyResolutionManagement {
    repositories {
        mavenCentral()
        google()
    }
}

Step 2: Apply the Plugin

Add the Monitor plugin to your app module's build.gradle.kts:

Kotlin
// app/build.gradle.kts
plugins {
    id("com.android.application")
    id("com.bytehide.monitor") version "1.0.1"
}

The plugin automatically adds the Monitor runtime library. No separate dependency needed.


Step 3: Configure

Add the monitor block with your token and the mobile preset:

Kotlin
monitor {
    projectToken = "bh_xxxxxxxxxxxx"
    preset = "mobile"
}

Monitor Gradle plugin configuration in Android StudioClick to expand

The mobile preset enables Debugger Detection, Clock Tampering, and Jailbreak Detection. A safe baseline for most Android applications. See Gradle Setup for all available presets.

No code changes required

The plugin generates a ContentProvider that auto-initializes Monitor when the app starts. All configuration is embedded at build time. You only need code if you want custom action handlers or runtime overrides.


Step 4: Build

Bash
./gradlew assembleDebug

You'll see Monitor configuring in the build output:

CODE
Configuring ByteHide Monitor...
  API Token: bh_POlhU6...
  Package: com.example.myapp
  Generating MonitorContentProvider...
  Registering provider in AndroidManifest.xml...
  Embedding encrypted resources...
ByteHide Monitor configured successfully

Step 5: Verify

Run the app and filter Logcat by tag ByteHideMonitor:

CODE
I/ByteHideMonitor: [I001_INIT_START] MonitorLogger initialized with 2 sinks
I/ByteHideMonitor: [I002_INIT_SUCCESS] ByteHideMonitor initialization complete
I/ByteHideMonitor: [I010_API_CONNECTED] Registering device...

Detected threats also appear in the ByteHide Dashboard.


What Happens at Runtime

  1. The plugin signs the assembly and embeds encrypted configuration into the APK at build time
  2. At app launch, the generated ContentProvider initializes Monitor automatically
  3. Monitor verifies the assembly signature to ensure the APK has not been tampered with
  4. Configured protection modules start running
  5. Threats are logged locally and reported to the ByteHide Dashboard

Next Steps

Previous
Introduction