测试广告单元
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
广告检查器支持以下测试:
- 实际使用场景测试:从应用中的广告单元加载广告。您可以打开广告检查器,查看从广告单元发出的请求的详细信息。
- 测试环境:直接在广告检查器中测试广告单元,无需前往应用界面。您可以同时测试多个广告单元、异步加载和查看测试广告请求,以及执行单一广告来源测试。
运行上下文无关测试时,您的请求不会携带在应用界面中运行所需的参数,包括面向儿童的处理配置、自定义定位、网络 extras 和不同尺寸。由于这些请求存在限制,我们建议您在应用的界面中使用上下文相关测试。
前提条件
在继续之前,请执行以下操作:
- 完成初始前提条件中的所有项目,以创建 Ad Manager 账号、设置测试设备、初始化 Google 移动广告 SDK 并安装最新版本。
- 启动广告检查器。
请求测试广告
虽然您的广告单元可能支持多种广告格式,但广告检查器不允许您选择要测试的格式,并且默认使用上次请求的格式。
如需在广告检查器中请求测试广告,请完成以下步骤。如需了解详情,请参阅广告检查器(Beta 版)。
在上下文中:
- 在测试设备上,前往应用的界面并加载广告。
- 打开广告检查器。在广告单元标签页中,找到您加载广告的广告单元。
- 在 SDK 请求日志中,查看您请求的测试广告的详细信息。
Out-of-context:
- 在广告单元标签页中,点按您的广告单元,然后点击请求测试广告。
- 在 SDK 请求日志中,查看您请求的测试广告的详细信息。

如果广告单元格式显示为 Unknown(未知),您会看到请求测试广告处于灰显状态。如果您为单个广告单元请求了多种格式,广告检查器会使用最后一个广告单元。
测试单个广告来源
广告检查器可以限制应用中的广告请求,以便仅投放来自单个出价或广告瀑布流广告来源的广告。这样,您便可以验证是否已正确与第三方适配器集成,以及广告来源是否按预期投放。
如需测试单个广告来源,请完成以下步骤:
在广告检查器中,点击单一广告来源测试切换开关。系统会显示单个广告来源测试对话框:

选择要测试的广告来源。之后,您会看到强制重启应用页面:

单一广告来源测试设置适用于您今后发出的所有广告请求。此测试不适用于该会话中之前已缓存的广告。我们建议您在应用单一广告来源测试时强制重启您的应用。此方法会使可能会展示的缓存广告失效,这些广告并非来自您所选的接收广告请求的广告来源。
重启应用后,所有广告单元展示位置都会尝试展示来自所选广告来源的广告。当单一广告来源测试处于有效状态时启动广告检查器,即会显示有效的测试广告来源:

在单一广告来源测试模式下,所有广告请求都会尝试从所选广告来源填充广告,无论是否针对出价或瀑布流配置了该广告来源。如果您要测试的广告来源未针对相应广告单元设置竞价或瀑布流,您会收到以下错误消息:
Ad Unit has no applicable adapter for single ad source testing on network: AD_SOURCE_ADAPTER_CLASS_NAME
如需验证广告来源是否在您开始单一广告来源测试后填充了广告请求,请点按某个广告单元以查看 SDK 请求日志。如果广告来源未能加载广告,则系统会显示一条错误消息,说明相应错误,例如 Adapter failed to initialize
。
如果您向某个瀑布流多次添加了所选广告来源,则会看到对该广告来源的每次调用。此过程会一直渲染,直到填充广告或广告瀑布流以无任何广告填充而结束。
停止单个广告来源测试
如需停止测试,请完成以下步骤:
- 在广告检查器中,关闭单一广告来源测试开关。系统会显示停止单一广告来源测试?对话框。
点按停止测试。

如果成功,强制重启应用上方会显示确认消息:

如需撤消测试的广告来源的缓存广告,我们建议您在停止测试后强制重启应用。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-31。
[null,null,["最后更新时间 (UTC):2025-08-31。"],[],[],null,["# Test ad units\n\nSelect platform: [Android](/ad-manager/mobile-ads-sdk/android/ad-inspector/test-ad-units \"View this page for the Android platform docs.\") [iOS](/ad-manager/mobile-ads-sdk/ios/ad-inspector/test-ad-units \"View this page for the iOS platform docs.\") [Unity](/ad-manager/mobile-ads-sdk/unity/ad-inspector/test-ad-units \"View this page for the Unity platform docs.\") [Flutter](/ad-manager/mobile-ads-sdk/flutter/ad-inspector/test-ad-units \"View this page for the Flutter platform docs.\")\n\n\u003cbr /\u003e\n\nAd inspector supports the following tests:\n\n- **In-context testing**: load ads from the ad units in your app. You can open ad inspector to view details on requests made from ad units.\n- **Out-of-context testing**: test your ad unit directly in ad inspector without navigating to your app's UI. You can test multiple ad units at once, asynchronously load and view your test ad requests, and perform single ad source tests.\n\nWhen running an out-of-context test, your requests don't carry the parameters\nto run in your app's UI, including child-directed treatment configuration,\ncustom targeting, network extras, and different sizes. Due to the limitation of\nthese requests, we recommend you use in-context testing in your app's UI.\n\nPrerequisites\n-------------\n\nBefore you continue, do the following:\n\n- Complete all items in the initial [Prerequisites](/ad-manager/mobile-ads-sdk/flutter/ad-inspector#prerequisites) to create an Ad Manager account, set your test device, initialize Google Mobile Ads SDK , and install the latest version.\n- [Launch ad inspector](/ad-manager/mobile-ads-sdk/flutter/ad-inspector/launch-ad-inspector).\n\nRequest a test ad\n-----------------\n\nThough your ad unit might support multiple ad formats, ad inspector doesn't let\nyou select which format to test, and defaults to the last requested format.\n\nTo request a test ad in ad inspector, complete the following steps. For more\ndetails, see\n\n[Ad inspector (Beta)](//support.google.com/admanager/answer/7180401#ad-inspector).\n\n\n- **In-context**:\n\n 1. On a test device, navigate to your app's UI and load an ad.\n 2. Open ad inspector. In the **Ad unit** tab, find the ad unit where you loaded the ad.\n 3. In **SDK request log**, view details on your requested test ad.\n- **Out-of-context**:\n\n 1. In the **Ad unit** tab, tap on your ad unit and click **Request test ad**.\n 2. In **SDK request log**, view details on your requested test ad.\n\nIf the ad unit format shows **Unknown** , you see **Request test ad** greyed\nout. If you request multiple formats for\na single ad unit, ad inspector uses the last ad unit.\n\n\nTest a single ad source\n-----------------------\n\nAd inspector can restrict ad requests in your app to serve ads from a single\nbidding or waterfall ad source. This approach lets you verify that you've\ncorrectly integrated with the third-party adapter, and the ad source serves\nas expected.\n\nTo test a single ad source, complete the following steps:\n\n1. In **Ad inspector** , click the **Single ad source test** toggle. A\n **Single ad source test** dialog appears:\n\n \u003cbr /\u003e\n\n\n2. Select an ad source to test. Afterwards, you receive the\n **Force restart app** page:\n\nThe single ad source test setting applies to any future ad requests you make.\nThis test doesn't apply to previously cached ads in that session.\nWe recommend you to force restarting your app when applying a single ad source\ntest. This approach invalidates cached ads that might display instead of\nyour chosen ad source receiving a request.\n\nAfter restarting your app, all ad unit placements attempt to show an ad from the\nselected ad source. Launching ad inspector when a single ad source test is\nactive shows the active test ad source:\n\nIn single ad source test mode, all ad requests attempt to fill with the\nselected ad source, regardless of whether that ad source was configured for\nbidding or waterfall. If the ad source you're testing is not set up for bidding\nor waterfall for the ad unit, you receive the following error message: \n\n Ad Unit has no applicable adapter for single ad source testing on network: \u003cvar translate=\"no\"\u003eAD_SOURCE_ADAPTER_CLASS_NAME\u003c/var\u003e\n\nTo verify whether the ad source filled the ad requests after you start a single\nad source test, tap an ad unit to view the SDK request log. If the ad source\nfailed to load an ad, an error message appears describing the error, such\nas `Adapter failed to initialize`.\n\nIf you've added multiple instances of the selected ad source to a waterfall, you\nsee each call instance to the ad source. This process renders until the ad is\neither filled or the waterfall ends without a fill.\n\nStop a single ad source test\n----------------------------\n\nTo stop the test, complete the following steps:\n\n1. In **Ad inspector** , click off the **Single ad source test** toggle. The **Stop single ad source test?** dialog appears.\n2. Tap **Stop test**.\n\n\n If successful, a confirmation message appears over **Force restart app**:\n\nTo revoke cached ads for the tested ad source, we recommend you to force\nrestart the app after stopping the test."]]