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.
- 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:
Define
manifestPlaceholdersproperties in your Gradle build file.Assign values for each build type. The following example defines the key
disableAdInspector, creates aprofilebuild type that inherits from thereleasebuild type. This example also sets the key value totruefor profile builds and afalsevalue for debug and release builds.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
android { buildTypes { release { manifestPlaceholders = [disableAdInspector: "false"] } debug { manifestPlaceholders = [disableAdInspector: "false"] } create("profile") { initWith(getByName("release")) manifestPlaceholders = [disableAdInspector: "true"] } } }
Reference the placeholder variable in your app's manifest file. The following example uses the
disableAdInspectorplaceholder that you defined in the previous step.<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>
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:
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.