Debugging

This guide shows how to debug creatives in your apps using in-app preview.

In-app preview lets you see your own creatives rendered within your mobile app. This preview is especially useful for publishers who have creatives that interact with the app, have unique behavior, or rely on the app for some of their rendering (including native creatives and MRAID).

The Delivery Inspector gives information on which ads were delivered. When unexpected ads deliver, use the Delivery Inspector to find out why.

Prerequisites

  • Version 10.2 or later of the Google Mobile Ads SDK
  • Access to a DFP account
  • Complete Get Started

Prepare your app

Debugging requires interaction with the SDK's debug options menu. The recommended way to open the menu is to include the function below in your app, and trigger it based on a user action:

public class MainActivity extends AppCompatActivity {

    ...

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // Initialize the Mobile Ads SDK.
        MobileAds.initialize(this);
    }

    ...

    // Opens a debug menu. Call this method based on a user action.
    public void openDebugMenu() {
        MobileAds.openDebugMenu(this, "YOUR_AD_UNIT_ID");
    }
 }

Any valid ad unit from your DFP account is sufficient to open the debug options menu.

After adding the capability to open the debug options menu, run your app and trigger the function above. The following menu opens:

Select Creative Preview to link your device. A browser opens and automatically navigates you to a browser to log in to DFP. After successfully logging in, name your device to register it with your DFP account, and click Verify.

You have successfully linked your device! At this point, you can see your device linked in the DFP front-end. You can also allow others to access your devices.

In-app preview

Follow the steps to push a creative to your linked device. Make sure that the pushed creative is part of an active line item targeted to the ad slot where you want to see the creative.

After pushing a creative from the front-end, trigger the debug options menu on your device again, and select Creative Preview again. This step lets the SDK check DFP again to verify that the device linking was successful and to get some information about which creative you pushed. If device linking was previously successful, the debug menu closes immediately. If it was unsuccessful, you're prompted to link your account again.

Finally, load an ad for the slot you wish to preview to see your creative!

Delivery Inspector

Follow the Begin app troubleshooting steps to troubleshoot your app. If you complete the steps successfully, the request will show up in the DFP frontend and you can view more info about the ad that served.

Send feedback about...

SDK for DFP Users on Android
Need help? Visit our support page.