简体   繁体   English

在Android中测试AdMob广告

[英]Test AdMob ads in Android

So I'm new to using AdMob and had a question on how to correctly use/implement it. 所以我是新手使用AdMob,并对如何正确使用/实现它有疑问。 Google tells me to use test ads while developing (if I use real ads it is a violation of their policy), how do I have test ads in development and then real ads in production or while my is in the play store? 谷歌告诉我在开发过程中使用测试广告(如果我使用真实广告违反了他们的政策),我如何在开发中使用测试广告,然后在制作中或在游戏商店中使用真实广告? I'm sure this is simple, thanks for your help! 我相信这很简单,谢谢你的帮助!

You can specify your device id as a test device: 您可以将设备ID指定为测试设备:

AdRequest adRequest = new AdRequest.Builder()
        .addTestDevice("0FA20932AFE1095798444FD9AAB7D425")
        .build();

Then whenever you run the application on this device, you get test ads, and on all the other devices you get the real deal. 然后,无论何时在此设备上运行应用程序,您都会获得测试广告,而在所有其他设备上,您将获得真正的优惠。

To get the device id, run your app with ads turned on and watch the log. 要获取设备ID,请在启用广告的情况下运行您的应用并观看日志。

You can specify a test banner ad unit id for dev versions. 您可以为开发版本指定测试横幅广告单元ID。 ca-app-pub-3940256099942544/6300978111 为ca-app-PUB-6300978111分之3940256099942544

The banner example provided by Google here specifies this in a string resource. 由谷歌提供的旗帜例如这里指定了该字符串中的资源。 Using gradle build flavours you could easily specify different resource files with different id's for dev and production. 使用gradle构建版本,您可以轻松地为开发和生产指定具有不同ID的不同资源文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM