<br />

While you can use ad inspector to inspect ad behavior during development,
testing, and troubleshooting, the tool might increase memory usage when
enabled. You might want to disable ad inspector during performance profiling and
memory checking. This feature makes sure that ad inspector doesn't run and
interfere with your app's performance measurements.

Disabling ad inspector prevents the tool from increasing memory usage or
launching through gestures, the debug menu, or method calls. You can disable
ad inspector while performance testing in test mode. In production, ad inspector
is always disabled and doesn't impact your app's performance.

This guide covers disabling ad inspector and verifying the disablement.

## Prerequisites

Before you continue, complete the following:

- [Set up GMA Next-Gen SDK](https://developers.google.com/admob/android/next-gen/quick-start.md.txt).
- Use GMA Next-Gen SDK version 1.3.0 or higher.

## Disable with build types

To keep ad inspector available in debug builds while disabling the tool in
profiling builds, manage the build configuration setting by

using Gradle build types and manifest placeholders.
Complete the following steps:

1. Define `manifestPlaceholders` properties in your Gradle build file.

2. Assign values for each build type. The following example defines the key
   `disableAdInspector`, creates a `profile` build type that inherits from the
   `release` build type. This example also sets the key value to `true` for
   profile builds and a `false` value for debug and release builds.

   ### Kotlin

   ```kotlin
   android {
       buildTypes {
           getByName("debug") {
               manifestPlaceholders["disableAdInspector"] = "false"
           }
           getByName("release") {
               optimization {
                   enable = false
               }
               manifestPlaceholders["disableAdInspector"] = "false"
           }
           create("profile") {
               initWith(getByName("release"))
               manifestPlaceholders["disableAdInspector"] = "true"
           }
       }
   }
   ```

   ### Groovy

   ```groovy
   android {
       buildTypes {
           release {
               manifestPlaceholders = [disableAdInspector: "false"]
           }
           debug {
               manifestPlaceholders = [disableAdInspector: "false"]
           }
           create("profile") {
               initWith(getByName("release"))
               manifestPlaceholders = [disableAdInspector: "true"]
           }
       }
   }
   ```
3. Reference the placeholder variable in your app's manifest file. The
   following example uses the `disableAdInspector` placeholder that you
   defined in the previous step.

   ```xml
   <application>
   <!-- Dynamically enable or disable ad inspector based on build type -->
   <meta-data
       android:name=
       "com.google.android.libraries.ads.mobile.sdk.flag.DISABLE_AD_INSPECTOR"
       android:value="${disableAdInspector}" />
   </application>
   ```

> [!NOTE]
> **Note:** During development and testing, make sure that you [enable test devices](https://developers.google.com/admob/android/next-gen/test-ads.md.txt#enable_test_devices).


## Verify the disablement

When you attempt to open ad inspector while it's disabled in the
`AndroidManifest.xml` file, you see the following message in Logcat:

```text
Ad inspector is disabled in the AndroidManifest.xml.
```

Calling the `MobileAds.openAdInspector` method returns an `AdInspectorError`
object in the callback, notifying the app that ad inspector can't open:

    Ad inspector cannot be opened because it is disabled in the AndroidManifest.xml.