广告加载错误
bookmark_borderbookmark
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
当广告加载失败时,系统会调用失败回调,以提供
LoadAdError
对象。
以下代码段会在广告加载失败时检索错误信息:
public void OnAdFailedToLoad(LoadAdError error)
{
// Gets the domain from which the error came.
string domain = error.GetDomain();
// Gets the error code. See
// https://developers.google.com/admob/android/reference/com/google/android/gms/ads/AdRequest
// and https://developers.google.com/admob/ios/api/reference/Enums/GADErrorCode
// for a list of possible codes.
int code = error.GetCode();
// Gets an error message.
// For example "Account not approved yet". See
// https://support.google.com/admob/answer/9905175 for explanations of
// common errors.
string message = error.GetMessage();
// Gets the cause of the error, if available.
AdError underlyingError = error.GetCause();
// All of this information is available via the error's toString() method.
Debug.Log("Load error string: " + error.ToString());
// Get response information, which may include results of mediation requests.
ResponseInfo responseInfo = error.GetResponseInfo();
Debug.Log("Response info: " + responseInfo.ToString());
}
此信息可用于更准确地确定导致广告出现的原因
加载失败。尤其是当网域为 com.google.admob
下的错误时,
iOS 和 Android 上的 com.google.android.gms.ads
,GetMessage()
可
在此帮助中心内查找过
文章,详细了解
说明以及可以采取哪些措施来解决问题。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-03-15。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-03-15。"],[[["When an ad fails to load, a `LoadAdError` object is provided in a failure callback, containing information about the error."],["The `LoadAdError` object provides access to the error domain, code, message, underlying cause, and response information."],["Developers can use the error code and message, especially for errors from `com.google.admob` or `com.google.android.gms.ads`, to diagnose and resolve ad loading issues with help from the provided resources."],["The `LoadAdError` object's `ToString()` method and `GetResponseInfo().ToString()` method offer comprehensive overviews of the error and response details for debugging."]]],["When an ad fails to load, the `LoadAdError` object provides details via a callback. Key actions include retrieving the error's domain using `GetDomain()`, the error code with `GetCode()`, and a descriptive message via `GetMessage()`. The underlying cause is accessible with `GetCause()`. All data is also in the `ToString()` method. `GetResponseInfo()` offers insights, possibly regarding mediation. `GetMessage()` can be researched in a specific article to resolve the cause of the ad loading failure.\n"]]