[null,null,["最后更新时间 (UTC):2025-08-31。"],[[["\u003cp\u003eThis guide helps you debug ad serving in your mobile app using in-app preview and Ad Manager delivery tools.\u003c/p\u003e\n"],["\u003cp\u003eIn-app preview lets you test your own creatives within your app, while delivery tools provide insight into ad delivery issues.\u003c/p\u003e\n"],["\u003cp\u003eTo use these tools, you'll need to integrate the Google Mobile Ads SDK, link your device to your Ad Manager account, and then trigger the debug menu in your app.\u003c/p\u003e\n"],["\u003cp\u003eYou can then push specific creatives to your linked device for previewing, or use delivery tools to diagnose unexpected ad behavior.\u003c/p\u003e\n"]]],[],null,["This guide shows how to debug ad serving using in-app preview and the Ad Manager\ndelivery tools.\n\n[In-app preview](//support.google.com/admanager/answer/7160685) lets you inspect\nyour own creatives rendered within your mobile app. This preview is especially\nuseful if you have creatives that interact with the app, have unique behavior,\nor rely on the app for some rendering (including native creatives and MRAID).\n\nThe [Ad Manager delivery tools](//support.google.com/admanager/answer/7449957)\ngive information on which ads were delivered; so when unexpected ads deliver,\nuse the delivery tools to find out why.\n\nPrerequisites\n\n- Version 10.2.0 or higher of the Google Mobile Ads SDK.\n\n- Access to a Google Ad Manager account.\n- Complete the [Get started guide](/ad-manager/mobile-ads-sdk/android/quick-start).\n\nPrepare your app\n\nDebugging requires interaction with the SDK's debug options menu. The\nrecommended way to open the menu is to include the following function in your\napp, and trigger it based on a user action: \n\nJava \n\n```java\npublic class MainActivity extends AppCompatActivity {\n\n ...\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n setContentView(R.layout.activity_main);\n\n // Initialize the Mobile Ads SDK.\n MobileAds.initialize(this);\n }\n\n ...\n\n // Opens a debug menu. Call this method based on a user action.\n // Replace YOUR_AD_UNIT_ID with your own ad unit ID.\n public void openDebugMenu() {\n MobileAds.openDebugMenu(this, \"YOUR_AD_UNIT_ID\");\n }\n}\n```\n\nKotlin \n\n```kotlin\nclass MainActivity : AppCompatActivity() {\n\n ...\n\n override fun onCreate(savedInstanceState: Bundle?) {\n super.onCreate(savedInstanceState)\n setContentView(R.layout.activity_main)\n\n // Initialize the Mobile Ads SDK.\n MobileAds.initialize(this)\n }\n\n ...\n\n // Opens a debug menu. Call this method based on a user action.\n // Replace YOUR_AD_UNIT_ID with your own ad unit ID.\n fun openDebugMenu() {\n MobileAds.openDebugMenu(this, \"YOUR_AD_UNIT_ID\")\n }\n}\n```\n\n\u003cbr /\u003e\n\n| **Key Point:** `MobileAds.initialize()` must be called before `MobileAds.openDebugMenu()`.\n\nAny valid ad unit from your Ad Manager account is sufficient to open the debug\noptions menu.\n\nAnother way to open the menu is to do a [long two-finger\npress](//support.google.com/admanager/answer/7180401) on the creative, but this\ndoesn't work for all ad formats, such as native ads, and you must be careful not\nto click the ad when attempting to swipe. Calling the previous method is much\nmore robust.\n\nLink your device\n\nAfter adding the capability to open the debug options menu, run your app and\ntrigger the function. The following menu opens:\n\nSelect **Creative Preview** to link your device. A browser opens and\nautomatically navigates you to a browser to sign in to Ad Manager. After signing\nin, name your device to register it with your Ad Manager account. Then click\n**Verify**.\n\nAt this point, you can verify that your device has been linked in the [Ad\nManager UI](//admanager.google.com/home/). You can also [let others access your\ndevices](//support.google.com/admanager/answer/7160685#make-public).\n\nIn-app preview\n\nFollow the steps to [push a creative to your linked\ndevice](//support.google.com/admanager/answer/7160685#push). Make sure that the\npushed creative is part of an active line item targeted to the ad slot where you\nwant the creative.\n\nAfter pushing a creative from the UI, trigger the debug options menu on your\ndevice again and select **Creative Preview** once more. This step lets the SDK\ncheck Ad Manager to verify that the device linking was successful and to get\nsome information about which creative you pushed. If device linking was\npreviously successful, the debug menu closes immediately. If it was\nunsuccessful, you're prompted to link your account again.\n\nFinally, load an ad for the slot you want to preview to see your creative.\n\nDelivery tools\n\nFollow the steps in [Inspect delivery in Ad\nManager](//support.google.com/admanager/answer/7180401#inspect-in-ui) to\ntroubleshoot your ad delivery. If you've completed the steps successfully, the\nrequest shows up in the Ad Manager UI and you can view more info about the ad\nthat served."]]