广告加载错误
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
如果广告加载失败,系统会调用一个失败回调,该回调会提供一个 LoadAdError
对象。
以下代码段会在激励广告加载失败时检索错误信息:
onAdFailedToLoad: (ad, loadAdError) {
// Gets the domain from which the error came.
String domain = loadAdError.domain;
// Gets the error code. See
// https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/AdRequest
// and https://developers.google.com/ad-manager/mobile-ads-sdk/ios/api/reference/Enums/GADErrorCode
// for a list of possible codes.
int code = loadAdError.code;
// A log friendly string summarizing the error.
String message = loadAdError.message;
// Get response information, which may include results of mediation requests.
ResponseInfo? responseInfo = loadAdError.responseInfo;
}
此信息可用于更准确地确定导致广告加载失败的原因。需要特别指出的是,对于网域 com.google.admob
(在 iOS 上)和 com.google.android.gms.ads
(在 Android 上)下的错误,可在这篇帮助中心文章中查询 GetMessage()
,以获取更多详细说明并了解可以采取哪些措施来解决相应问题。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-25。
[null,null,["最后更新时间 (UTC):2025-08-25。"],[[["\u003cp\u003eWhen an ad fails to load, a \u003ccode\u003eLoadAdError\u003c/code\u003e object is provided in the failure callback, containing details about the error.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eLoadAdError\u003c/code\u003e object provides information such as the error domain, code, message, and response details for debugging purposes.\u003c/p\u003e\n"],["\u003cp\u003eFor errors originating from Google AdMob (domains \u003ccode\u003ecom.google.admob\u003c/code\u003e or \u003ccode\u003ecom.google.android.gms.ads\u003c/code\u003e), further information and troubleshooting steps can be found in the AdMob help center article linked in the documentation.\u003c/p\u003e\n"]]],["When an ad fails to load, a `LoadAdError` object is provided via a callback. This object contains error details, including the error's domain, a specific error code, a summarized message, and response information that could be related to mediation. For errors originating from `com.google.admob` (iOS) or `com.google.android.gms.ads` (Android), the message can be checked in a help center article for in-depth information and potential solutions. This information helps to pinpoint the cause of ad loading failure.\n"],null,["# Ad load errors\n\nSelect platform: [Android](/ad-manager/mobile-ads-sdk/android/ad-load-errors \"View this page for the Android platform docs.\") [iOS](/ad-manager/mobile-ads-sdk/ios/ad-load-errors \"View this page for the iOS platform docs.\") [Unity](/ad-manager/mobile-ads-sdk/unity/ad-load-errors \"View this page for the Unity platform docs.\") [Flutter](/ad-manager/mobile-ads-sdk/flutter/ad-load-errors \"View this page for the Flutter platform docs.\")\n\n\u003cbr /\u003e\n\nWhen an ad fails to load, a failure callback is called which provides a\n`LoadAdError` object.\n\nThe following code snippet retrieves error information when a rewarded ad fails\nto load: \n\n onAdFailedToLoad: (ad, loadAdError) {\n // Gets the domain from which the error came.\n String domain = loadAdError.domain;\n\n // Gets the error code. See\n // https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/AdRequest\n // and https://developers.google.com/ad-manager/mobile-ads-sdk/ios/api/reference/Enums/GADErrorCode\n // for a list of possible codes.\n int code = loadAdError.code;\n\n // A log friendly string summarizing the error.\n String message = loadAdError.message;\n\n // Get response information, which may include results of mediation requests.\n ResponseInfo? responseInfo = loadAdError.responseInfo;\n }\n\nThis information can be used to more accurately determine what caused the ad\nload to fail. In particular, for errors under the domain `com.google.admob` on\niOS and `com.google.android.gms.ads` on Android, the `GetMessage()` can be\nlooked up in [this help center\narticle](//support.google.com/admob/answer/9905175) for a more detailed\nexplanation and possible actions that can be taken to resolve the issue."]]