Google 互動式媒體廣告 SDK 常見問題
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
- 為什麼我無法取回所有格式的廣告?
-
測試廣告代碼的設定是一律針對有效請求傳回廣告。這是
不但有利於整合,也能方便您測試播放器
請求及顯示廣告不過,並非每一種
網站、帳戶或廣告單元的格式。如果整合項目運作正常
測試代碼能正常運作,但不適用於您自己的代碼,原因可能是以下
包括:
- 您放送的影片格式不受支援。例如:
您只在 iOS 或 Android 上放送 HTML5 廣告。
- 如果您使用的是 Ad Manager,您的發布商 ID 可能目前沒有任何廣告指定至
並確認已核准相關廣告和
廣告素材。
- 如果您使用的是 AdSense,您網站或測試頁的指定條件可能會
沒有任何有效的廣告。最常見的原因是
私人且未檢索的網站。
- 如果您使用 Ad Exchange「聯播網夥伴管理」功能
descriptionURL
未設定或不在自有自營上
網域管理清單上的廣告,廣告就不會在這個網址放送。
- 查看 Ad Exchange 影片廣告中定義的「最低千次曝光出價」門檻。minCPMA 罩杯
千次曝光出價非常高,廣告供應率可能就會非常低。若要修正此問題,請嘗試
請從廣告請求中移除最低千次曝光出價,或移除廣告單元參數
(例如 Slotname),確認廣告是否會影響供應率。
- 怎樣的
descriptionUrl
才算合適?
-
最有效的方式如下:
descriptionUrl
的網頁內容
不該是一系列的字詞或詞組
1 到 3 段文字,用來實際說明內容,以及您在提供該內容時所扮演的角色。
我們過去已將其成功
根據預先定義區塊動態建立「descriptionUrl
」網頁內容。
例如,這是幾個用來描述內容的句子、幾個用來說明
而是一些預先定義的摘要
AdSense 頻道 (例如「娛樂」或「運動」)。因此,每一層
內容的相關descriptionUrl
與
這可以同時提供一般資訊 (例如類型描述元)
具體資訊 (與內容直接相關)。
這個中繼資料 HTML 應該要很簡潔,例如:
<html>
<head>
<title>Domain.com - Your tag line here!</title>
</head>
<body>
<h1>Descriptions</h1>
<h2>About this Content</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. ...</p>
<h2>About Domain.com</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. ...</p>
</body>
</html>
- 為什麼我收到了「廣告回應未包含有效的廣告類型」錯誤?
- 這個錯誤通常出現,因為您並未將任何廣告指定至
特定
publisherId
(在指定時間範圍內)。這個條件
在廣告活動的開始和結束的一天或數天內,可能會有所不同。
請檢查要指定的廣告尚未過期
廣告指定條件正確無誤。
只要廣告能使用
測試 publisherId
就能確保這些廣告
當廣告正常放送時,系統會使用您的有效 publisherId
正確處理
廣告。
- Google 是否提供測試用的 Ad Manager 影片廣告代碼?
- 請前往「範例代碼」頁面取得範例代碼。
- 我應該將
adSlotWidth
和 adSlotHeight
設為相同的值
做為 Ad Manager 廣告代碼中的 sz
嗎?
- 不一定。《
adSlotWidth
》和《adSlotHeight
》
必須設為廣告目標播放器或區域的寬度/高度
填滿。AdSense 會使用這些參數判斷哪些廣告有空
在這個空間中Ad Manager 廣告代碼中的 sz
鍵/值組合為
指定目標參數,不一定會影響放送的廣告素材
(詳情請見下文)。
- 示範的廣告代碼看起來很棒,但是當我切換成我的廣告代碼時,卻沒有出現廣告。
-
檢查以確定有廣告投放至您的廣告代碼
資源。最簡單的方法就是觀察 HTTP 流量。如果
HTML 錨定區塊中傳回 1x1 pixel grey.gif 圖片,
您必須在 Ad Manager 中檢查指定目標
- 我想多次使用相同代碼來請求廣告,但只產生第一個廣告
請求。該如何解決這個問題?
-
多次請求廣告時,請務必讓廣告伺服器知道
這些是合法要求,並非意外重複。SDK
就可以透過兩項快速 API 呼叫來達成這個目的:
- 在
AdsManager
執行個體上呼叫 destroy()
。
這樣當您以下列呼叫
contentComplete()
。您可獲得新的 AdsManager
有助於您提出下一個要求
- 透過
AdsLoader
呼叫 contentComplete()
執行個體。這會重設 SDK,因此新的廣告請求看起來像
重複項目的副本
,瞭解如何調查及移除這項存取權。
完成上述兩個呼叫後,您可以在下列位置呼叫 requestAds()
:
您的 AdsLoader
例項,以便替您的
新增影片
- 如何使用 IMA SDK 請求重疊廣告和全版位 AdSense 廣告?
-
如要使用 SDK 請求 AdSense 廣告,您必須先取得 AdSense
廣告代碼。詳細資訊請見 AdSense
。取得代碼後,您必須執行以下操作
提出重疊或完整版位廣告請求的步驟:
重疊廣告
- 在
AdsRequest
中,將 ViewModes 設為
NORMAL
。
- 在廣告代碼中,新增參數
overlay=1
。
,瞭解如何調查及移除這項存取權。
全版位廣告
- 在
AdsRequest
中,將 ViewModes 設為
FULLSCREEN
。
- 在廣告代碼中,新增參數
overlay=0
。
- 我看到「無效的到達網址」發生錯誤請問可能原因為何?
-
發生此錯誤的最常見原因為 4 錯誤逸出的點閱
網址。如果您看到這個錯誤,請檢查以確認點閱率
VAST 回應中的網址正確逸出。
- 在 Android 和 iOS SDK 中,有辦法將整個影片廣告設為可點擊嗎?
- 截至目前為止,整部影片的點擊追蹤技術都適用,為觀眾提供一般觀影體驗
登上影片排行榜的前提
或是開啟播放器控制項避免使用者
使用者不小心按到廣告
播放器控制 IMA 會使用 [瞭解詳情] 按鈕
當使用者按下廣告,並進一步瞭解所宣傳的產品。
- 為什麼我會看到「VAST 文件空白」錯誤訊息?
- 如果廣告代碼傳回空白的 VAST 文件,就會發生這個錯誤。
廣告無法正常放送請洽詢客戶經理
或廣告伺服器代表,瞭解廣告代碼無法運作的原因。
- 我可以變更「略過廣告」方塊或其他 UI 元素的大小/文字嗎?
- IMA SDK 不支援變更 UI 元素的版面配置、大小或內容。
如要進一步瞭解 UI 元素,請參閱
AdsManager.uiElements
。
- 為什麼我會收到「沒有虛擬方法」發生錯誤?
-
出現類似下列錯誤訊息的原因,都是使用舊版本
不含廣告 ID 的 Google Play 服務。
No virtual method
getInfo()Lcom/google/android/gms/ads/identifier/AdvertisingIdClient$Info; in
class Lcom/google/android/gms/ads/identifier/AdvertisingIdClient; or its
super classes (declaration of 'com.google.android.gms.ads.identifier.AdvertisingIdClient'
升級至 4.0 以上版本 (最好是最新版本) 就能解決這個問題。
- 我可以使用多個執行緒初始化及操控 UI 嗎?
-
不行,所有 UI 的初始化及操作都必須在
主執行緒。在 Android 中,UI 物件並非安全執行緒。詳情請見
執行緒。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-31 (世界標準時間)。
[null,null,["上次更新時間:2025-08-31 (世界標準時間)。"],[[["\u003cp\u003eThe test ad tags always return ads for valid requests to help with integration and testing; however, live ads might not always be available due to factors like ad targeting, formats, and publisher settings.\u003c/p\u003e\n"],["\u003cp\u003eWhen using your own ad tag, ensure it's properly trafficked and targeted in Ad Manager to avoid issues like no ads appearing or a 1x1 pixel grey.gif being returned.\u003c/p\u003e\n"],["\u003cp\u003eFor repeated ad requests using the same tag, use \u003ccode\u003edestroy()\u003c/code\u003e on the \u003ccode\u003eAdsManager\u003c/code\u003e and \u003ccode\u003econtentComplete()\u003c/code\u003e on the \u003ccode\u003eAdsLoader\u003c/code\u003e to prevent duplicate requests and ensure proper ad serving.\u003c/p\u003e\n"],["\u003cp\u003eAn "Ad response does not contain a valid ad type" error usually indicates an issue with ad targeting for your publisher ID; verify the ad's status and targeting criteria in Ad Manager.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eadSlotWidth\u003c/code\u003e and \u003ccode\u003eadSlotHeight\u003c/code\u003e should be set to the player's dimensions for ad fitting, while the \u003ccode\u003esz\u003c/code\u003e parameter in the Ad Manager tag is for targeting and may not directly influence creative selection.\u003c/p\u003e\n"]]],[],null,["# Google Interactive Media Ads SDK FAQs\n\n- [Why am I not getting ads back for all formats?](#1)\n- [What does a good descriptionUrl look like?](#2)\n- [Why am I receiving the error \"Ad response does not contain a valid ad type\"?](#3)\n- [Do you have an Ad Manager video ad tag that I can use for testing?](#4)\n- [Should I set the adSlotWidth and adSlotHeight to the same values\n as the sz in my Ad Manager ad tag?](#5)\n- [The demo ad tag looks great, but when I switch it with my ad tag,\n no ad appears.](#7)\n- [I want to request ads using the same tag more than once, but I\n only get ads for my first request. How do I fix this?](#8)\n- [How do I request overlay and full slot AdSense ads using the IMA\n SDK?](#9)\n- [I'm getting an \"Invalid clickthrough URL\" error when I click on my\n ad. What could be the cause?](#10)\n- [In the Android and iOS SDKs, is there a way to make the entire video\n ad clickable?](#11)\n- [Why do I see a \"VAST Document Empty\" error?](#12)\n- [Can I change the size/text of the \"Skip Ad\" box or other UI elements?](#13)\n- [Why am I getting \"No virtual method\" errors at runtime?](#14)\n- [Can I use multiple threads to initialize and manipulate the UI?](#18)\n\n*** ** * ** ***\n\nWhy am I not getting ads back for all formats?\n:\n The test ad tags are set up to always return ads for valid requests. This is\n meant to facilitate integration and make it easier to test how your player\n requests and renders ads. However, ads are not always available in every\n format for your site, account, or ad unit. If your integration is working\n properly for the test tag but not for your own tag, the cause may be one of\n the following:\n\n - You're serving videos of an unsupported format to your environment. For example, you're serving only HTML5 ads to iOS or Android.\n - If you're using Ad Manager, your publisher ID may not have any ads targeted to it at this time. Also, ensure that you have approved the relevant ads and creatives in Ad Manager.\n - If you're using AdSense, the targeting criteria for your site or test page may not have any active advertisements. The most common cause is the use of private, uncrawled websites.\n - If you're using Ad Exchange Network Partner Management and `descriptionURL` is not set or is not on the owned or operated domains management list, ads do not serve to this.\n - Check the *minCPM* thresholds defined in Ad Exchange Video. A fairly high CPM may result in very low fill rates. To correct this, try either removing the minCPM or removing the ad unit parameter from the ad request (i.e., slotname) to verify whether this is affecting the fill rate.\n\nWhat does a good `descriptionUrl` look like?\n:\n To be most effective, the content of the page that `descriptionUrl`\n points to shouldn't be a collection of words or phrases but rather\n 1-3 paragraphs actually describing the content and your role in providing it.\n One method that has been successful in the past is to stitch together\n `descriptionUrl` page content dynamically from predefined blocks.\n For example, a few sentences about the content, a few sentences about your\n site's offering, and then a few predefined snippets associated with each\n AdSense channel (like \"Entertainment\" or \"Sports\"). As a result, each piece of\n content has a reasonably distinct `descriptionUrl` associated with\n it that provides both general information (such as genre descriptors) as well\n as specific information (content about the content directly).\n\n This metadata HTML should be simple, for example:\n\n ```text\n \u003chtml\u003e\n \u003chead\u003e\n \u003ctitle\u003eDomain.com - Your tag line here!\u003c/title\u003e\n \u003c/head\u003e\n \u003cbody\u003e\n \u003ch1\u003eDescriptions\u003c/h1\u003e\n \u003ch2\u003eAbout this Content\u003c/h2\u003e\n \u003cp\u003eLorem ipsum dolor sit amet, consectetur adipiscing elit. ...\u003c/p\u003e\n \u003ch2\u003eAbout Domain.com\u003c/h2\u003e\n \u003cp\u003eLorem ipsum dolor sit amet, consectetur adipiscing elit. ...\u003c/p\u003e\n \u003c/body\u003e\n \u003c/html\u003e\n \n ```\n\nWhy am I receiving the error \"Ad response does not contain a valid ad type\"?\n: This error generally appears because no ads have been targeted to the\n specific `publisherId` (for the given time period). This condition\n may vary throughout the day, or over several days as campaigns begin and end.\n You should check that the ad you wish to target has not expired and that the\n ad targeting criteria are correct.\n As long as ads are properly requested, received, and rendered using\n the test `publisherId`, you can be sure that these ads are\n properly handled using your live `publisherId` when the ads are\n available.\n\nDo you have an Ad Manager video ad tag that I can use for testing?\n: Sample tags are available on the [sample tags](/interactive-media-ads/docs/sdks/android/client-side/tags) page.\n\nShould I set the `adSlotWidth` and `adSlotHeight` to the same\nvalues as the `sz` in my Ad Manager ad tag?\n: Not necessarily. The `adSlotWidth` and `adSlotHeight`\n must be set to the width/height of the player or area you want your ads to\n fill. They are used by AdSense to determine which ads are available to fit\n into that space. The `sz` key/value pair in your Ad Manager ad tag is\n a targeting parameter and does not necessarily affect the creative served\n (more information below).\n\nThe demo ad tag looks great, but when I switch it with my ad tag, no ad appears.\n:\n Check to ensure that something is trafficked to the ad tag you are\n requesting. The easiest way to find out is to watch the HTTP traffic. If a\n **1x1 pixel grey.gif** image is returned within an HTML anchor block,\n then you need to check your targeting in Ad Manager.\n\nI want to request ads using the same tag more than once, but I only get ads for my first\nrequest. How do I fix this?\n:\n When you request ads more than once, you need to let the ad server know\n that these are legitimate requests, and not accidental duplicates. The SDK\n does this for you with two quick API calls:\n\n 1. Call `destroy()` on your `AdsManager` instance. This prevents any post-rolls from playing when you make the below call to `contentComplete()`. You get a new `AdsManager` when you make your next request.\n 2. Call `contentComplete()` on your `AdsLoader` instance. This resets the SDK so the new ad request doesn't look like a duplicate of the previous one.\n\n\n After making the two calls above, you can call `requestAds()` on\n your `AdsLoader` instance to get another set of ads to play for your\n new video.\n\nHow do I request overlay and full slot AdSense ads using the IMA SDK?\n\n: To request AdSense ads using the SDK, you need to first obtain an AdSense\n ad tag. You can learn more about that on the [AdSense\n for Video page](//support.google.com/adsense/answer/1705822). Once you have your tag, you need to take the following\n steps to make either an overlay or a full slot ad request:\n\n **Overlay ads**\n\n 1. In your `AdsRequest`, set your ViewModes to `NORMAL`.\n 2. In your ad tag, add the parameter `overlay=1`.\n\n **Full slot ads**\n\n 1. In your `AdsRequest`, set your ViewModes to `FULLSCREEN`.\n 2. In your ad tag, add the parameter `overlay=0`.\n\nI'm getting an \"Invalid clickthrough URL\" error when I click on my ad. What could be the cause?\n:\n The most common cause for this error is an improperly escaped clickthrough\n URL. If you're seeing this error, check to make sure that your clickthrough\n URL is properly escaped in your VAST response.\n\nIn the Android and iOS SDKs, is there a way to make the entire video ad clickable?\n: As far as whole-video click tracking goes, the standard viewer experience\n for mobile video that has emerged is that tapping on a video either\n pauses it or brings up the player controls. To avoid users\n unintentionally clicking on ads when they really just want access to the\n player controls IMA uses the **Learn more** button to let\n users click on an ad and learn more about the product being advertised.\n\nWhy do I see a \"VAST Document Empty\" error?\n: This error occurs when the ad tag returns an empty VAST document, indicating\n that the ad was not served properly. Talk to your account manager\n or ad server representative to see why your ad tag is not working.\n\nCan I change the size/text of the **Skip Ad** box or other UI elements?\n: The IMA SDKs do not support changing the layout, size, or content of UI elements.\n For more details on UI elements, see `AdsManager.uiElements`.\n\nWhy am I getting \"No virtual method\" errors at runtime?\n\n: Error messages similar to the following are caused by using an older version\n of Google Play services that does not include the advertising ID.\n\n ```\n No virtual method\n getInfo()Lcom/google/android/gms/ads/identifier/AdvertisingIdClient$Info; in\n class Lcom/google/android/gms/ads/identifier/AdvertisingIdClient; or its\n super classes (declaration of 'com.google.android.gms.ads.identifier.AdvertisingIdClient'\n ```\n\n Upgrading to version 4.0 or later (but preferably the latest) solves this problem.\n\nCan I use multiple threads to initialize and manipulate the UI?\n:\n\n No, all initialization and manipulation of the UI must be done on the\n main thread. In Android, UI objects are not thread-safe. See\n [Threads](//developer.android.com/guide/components/processes-and-threads.html#Threads) for more information."]]