This guide explains how to enable test ads in your ads integration. It is important to enable test ads during development so that you can click on them without charging Google advertisers. If you click on too many ads without being in test mode, you risk your account being flagged for invalid activity.
There are two ways to get test ads:
- Complete Get Started.
Sample ad units
The quickest way to enable testing is to use Google-provided test ad units. These ad units are not associated with your AdMob account, so there's no risk of your account generating invalid traffic when using these ad units. Here are sample ad units for each format:
|Ad format||Sample ad unit ID|
|Native Express||(Small template):
These ad units point to specific test creatives.
Enable test devices
The alternative way of serving test ads is to keep your regular ad unit ID, but configure your device as a test device. When a device is configured as a test device, the Google Mobile Ads SDK automatically substitutes in the aforementioned sample ad unit ID, limiting that device to receiving test ads.
Follow the steps below to configure your device as a test device.
Add your test device
- Load your ads-integrated app and make an ad request.
- Check the logcat output for a message that looks like this:
I/Ads: Use AdRequest.Builder.addTestDevice("33BE2250B43518CCDA7DE426D04EE232") to get test ads on this device.Copy your test device ID to your clipboard.
- Modify your code to call
AdRequest.Builder.addTestDevice()with your test device ID. This method can be called multiple times for multiple devices.
AdRequest request = new AdRequest.Builder() .addTestDevice("33BE2250B43518CCDA7DE426D04EE232") .build();
You can optionally check
to confirm that your device was properly added as a test device.