廣告載入錯誤
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 和 com.google.android.gms.ads
,GetMessage()
可以是
請參閱說明中心
一文,瞭解
說明,以及可採取哪些行動來解決問題。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間: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"]],["上次更新時間: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"]]