我一直试图让AdMob在我的应用上工作一段时间.我一直在日志中获取onFailedToRecieveAd(无效广告请求)消息.我已将我的测试应用程序与此配对:
AdView adView;
LinearLayout ll;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
adView = new AdView(this, AdSize.BANNER, "pub-2...............");//inserted my 16 digit pub id here
adView.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL);
ll = new LinearLayout(this);
ll.setOrientation(LinearLayout.VERTICAL);
ll.addView(adView);
setContentView(ll);
AdRequest adRequest = new AdRequest();
adRequest.addTestDevice("3...............");// 16 digits, tried other strings as
// follows:
//for addTestDevice I've tried several numbers, including the 16 digit device
// number given me by my "device id" application, the "0123456789ABCDEF" device number
// given by my console and device windows, the "CECE.........................." 32 digit
// device number my logcat file told me to use in a logcat message,
// "AdRequest.TEST_EMULATOR"
// which an admob example in the docs said to use, "9774d56d682e549c" which another
// admob docs example said to use.
adView.loadAd(adRequest);
Run Code Online (Sandbox Code Playgroud)
我也尝试了adView.loadAd(new AdRequest()); 在另一个google admob示例应用中使用无设备ID.
什么都没有显示任何东西,它甚至没有为广告创建空间,只是logcat中的onFailedToRecieveAd(无效广告请求)消息
我还在清单中包含了必要的权限和"com.google.ads.AdActivity".
And*_*der 14
哇,经过几天的挫折和各种论坛的帖子,我找到了答案.
您必须在Admob网站上转到您的帐户,为admob广告设置您的特定应用,并获得新的更长的发布商编号.我的发布商编号只以'pub -......'开头,我的新号码更长,以'ca-app-pub -.......'开头.当我在一个示例横幅ap中看到'ca-app-pub'前言时,我从一开始就很好奇.
谷歌Admob"谷歌移动广告SDK"开发网站上没有"横幅广告1"说明(https://developers.google.com/mobile-ads-sdk/docs/admob/fundamentals?hl=zh_CN#android)它是否提到必须返回到您的admob帐户才能设置特定的广告应用并获得新的发布商编号.
愚蠢的错误是最难修复的.
| 归档时间: |
|
| 查看次数: |
5126 次 |
| 最近记录: |