Trong trường hợp quảng cáo không tải được, một lệnh gọi lại sẽ được gọi để cung cấp đối tượng LoadAdError.
Đối với AdManagerAdView, lệnh gọi sau đây sẽ được thực hiện:
Kotlin
fun onAdFailedToLoad(error: LoadAdError)
Java
public void onAdFailedToLoad(LoadAdError adError);
Ví dụ sau đây cho thấy thông tin có sẵn khi không tải được quảng cáo:
Kotlin
override fun onAdFailedToLoad(error: LoadAdError) {
// Gets the domain from which the error came.
val errorDomain = error.domain
// Gets the error code. See
// https://developers.google.com/admob/android/reference/com/google/android/gms/ads/AdRequest#constant-summary
// for a list of possible codes.
val errorCode = error.code
// Gets an error message.
// For example "Account not approved yet". See
// https://support.google.com/admob/answer/9905175 for explanations of
// common errors.
val errorMessage = error.message
// Gets additional response information about the request. See
// https://developers.google.com/admob/android/response-info
// information.
val responseInfo = error.responseInfo
// Gets the cause of the error, if available.
val cause = error.cause
// All of this information is available using the error's toString() method.
Log.d("Ads", error.toString())
}Java
@Override
public void onAdFailedToLoad(@NonNull LoadAdError adError) {
// Gets the domain from which the error came.
String errorDomain = adError.getDomain();
// Gets the error code. See
// https://developers.google.com/admob/android/reference/com/google/android/gms/ads/AdRequest#constant-summary
// for a list of possible codes.
int errorCode = adError.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 errorMessage = adError.getMessage();
// Gets additional response information about the request. See
// https://developers.google.com/admob/android/response-info
// information.
ResponseInfo responseInfo = adError.getResponseInfo();
// Gets the cause of the error, if available.
AdError cause = adError.getCause();
// All of this information is available using the error's toString() method.
Log.d("Ads", adError.toString());
}Gỡ lỗi thông điệp nhật ký lỗi thường gặp
Trong phiên bản 23.5.0 của Google Mobile Ads SDK (Legacy), tính năng ghi nhật ký chi tiết đã được cải tiến để bao gồm dấu vết ngăn xếp của vị trí quảng cáo không tải được. Những thông báo này không cho biết sự cố mà xác định nguồn lỗi duy nhất. Bảng sau đây cung cấp nhật ký lỗi, nội dung mô tả và hành động đề xuất để giải quyết các lỗi thường gặp:
| Nhật ký lỗi | Mô tả | (Các) hành động được đề xuất |
|---|---|---|
com.google.android.gms.ads.nonagon.render.cp: * |
Máy chủ quảng cáo không trả về quảng cáo hoặc bất kỳ nguồn quảng cáo dàn xếp nào cho yêu cầu. | Để biết thông tin chi tiết về cách khắc phục sự cố không có lượt hiển thị, hãy xem bài viết Khắc phục sự cố về lượt hiển thị không được đáp ứng. |
com.google.android.gms.ads.nonagon.render.e: * |
Tất cả nguồn quảng cáo trong quy trình dàn xếp kiểu thác nước đều không tải được. Lỗi cụ thể cho biết nguồn quảng cáo gần đây nhất không tải được. | Để biết thông tin chi tiết về cách ghi nhật ký lý do không thành công của từng nguồn quảng cáo dàn xếp, hãy xem phần Thông tin phản hồi. |
com.google.android.gms.ads.internal.util.*: Unable to obtain a JavascriptEngine. |
Yêu cầu quảng cáo không thành công vì WebView không được phép trong các quy trình đặc quyền. |
|
| Yêu cầu quảng cáo không thành công do kết nối mạng chậm. | Hãy thử cải thiện kết nối Internet rồi thử lại. | |
com.google.android.gms.ads.nonagon.load.a |
Yêu cầu quảng cáo đã hết thời gian chờ. | |
com.google.android.gms.ads.internal.util.*: Error while
connecting to ad server: Unable to resolve host "pubads.g.doubleclick.net":
No address associated with hostname |
Yêu cầu quảng cáo không thành công do kết nối mạng. | |
com.google.android.gms.ads.internal.util.*: Error building
request URL: Cannot determine request type. Is your ad unit id correct? |
Mã đơn vị quảng cáo không khớp với biểu thức chính quy dự kiến. | Kiểm tra xem mã đơn vị quảng cáo của bạn có chính xác không. |
com.google.android.gms.ads.internal.render.bt: Unable to
instantiate mediation adapter class. |
Google Mobile Ads SDK (Legacy) không tìm thấy bộ chuyển đổi dàn xếp. |
|
com.google.android.gms.internal.ads.*: Received error HTTP response code: 403 |
Máy chủ Ad Manager đã từ chối yêu cầu. | Hãy thử lại sau. Nếu lỗi này liên tục xảy ra, hãy ghi lại URL yêu cầu bằng công cụ kiểm tra quảng cáo và liên hệ với nhóm hỗ trợ. |