---
title: Gradle Plugin
description: The Coralogix Gradle Plugin enables automatic network instrumentation for your Android project.
url: https://coralogix.com/docs/user-guides/rum/sdk-installation/android/gradle-plugin/
product: rum
feature: Android SDK
feature_id: mobile-sdk-android
feature_identifier: rum/mobile-sdk-android
last_updated: '2026-08-12'
---

# Coralogix Gradle plugin

The **Coralogix Gradle Plugin** enables automatic network instrumentation for your Android project. It works by injecting the Coralogix interceptor into all `OkHttpClient.Builder` instances — including those created by third-party libraries — ensuring complete visibility into your app’s network traffic without manual setup.

## Overview

When applied, the plugin uses **ASM bytecode transformation** at build time to automatically attach the `CoralogixOkHttpInterceptor` to every OkHttp client.

This guarantees that all network requests are automatically traced and reported to Coralogix, providing insights into request latency, failures, and performance bottlenecks.

## Installation

Add the plugin to your project’s `build.gradle` plugin management block.

### Option 1 — Gradle plugin portal (Recommended)

In your **root** `build.gradle`:

```
plugins {

    id("com.coralogix.gradle.plugin") version "2.27.0" apply false

}
```

Then, apply the plugin in your **app** module:

```
plugins {

    id("com.coralogix.gradle.plugin")

}
```

### Option 2 — using classpath dependency (Legacy)

In your **root** `build.gradle`:

```
buildscript {

    dependencies {

        classpath "com.coralogix.gradle.plugin:gradle-plugin:2.27.0"

    }

}
```

Then, apply the plugin in your **app** module:

```
apply plugin: "com.coralogix.gradle.plugin"
```

This plugin depends on the [Coralogix Android SDK](https://coralogix.com/docs/user-guides/rum/sdk-installation/android.md), because the classes it injects are part of the SDK.

Note

The minimum required Coralogix Android SDK version is `2.5.4`, using the plugin with an older version would result in unexpected behavior and potentially errors.

## Configuration

You can configure the plugin using the `coralogix` extension in your module’s `build.gradle` file.

```
coralogix {

    enabled = true   // Enable or disable the plugin globally

    log = false      // Enable logging of transformation activity (for debugging)

}
```

| Property    | Type      | Default | Description                                                                     |
| ----------- | --------- | ------- | ------------------------------------------------------------------------------- |
| **enabled** | `Boolean` | `true`  | Enables or disables automatic OkHttp instrumentation (true by default).         |
| **log**     | `Boolean` | `false` | Prints ASM transformation logs to the console for debugging (false by default). |

## How it works

The plugin integrates with the Android Gradle Plugin (AGP) and uses ASM to modify OkHttp’s bytecode.

During the build process:

1. The plugin scans for all classes implementing `okhttp3.OkHttpClient$Builder`.
2. It injects a static call to the bridge method `CxNetAutoAttach.attach()`.
3. The bridge automatically attaches `CoralogixOkHttpInterceptor` to any client built using that builder.

This means **every OkHttp request**, even those created deep inside third-party SDKs, will be captured and logged by Coralogix.

## Example output

When `log = true`, you’ll see logs during the build indicating which variants were instrumented:

```
[Coralogix] Inject bridge in OkHttpClient.Builder.<init>

[Coralogix] Plugin enabled on variant: release
```

## 🧾 License

```
Copyright (c) 2025 Coralogix

Licensed under the Apache License, Version 2.0
```
