Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does adRequest.addTestDevice("device_id") mean?

Tags:

android

admob

I'm confused about admob adrequest. I don't understand adRequest.addTestDevice("device_id").

If I write:

AdRequest adRequest = new AdRequest.Builder()
                .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
                .addTestDevice(DeviceInfo.getDeviceId(activity)).build();

for every single device, will it affect my AdMob account? Or is addTestDevice("deviceid") only for each testing device or real life device? If I add only my test device's id to AdRequest then will it display the ad to other devices or not?

like image 338
Mr X Avatar asked Jun 08 '15 07:06

Mr X


3 Answers

According to the docs:

It's important to make sure you always request test ads when developing and testing your applications. Testing with live, production ads is a violation of AdMob policy and can lead to suspension of your account. For more information on how to use test ads, see our Ad Targeting guide.

This means your account won't be affected when utilizing test ads regardless of the number of devices/emulators you use. Basically addTestDevice("deviceid") prevents generating false impressions and ensures test ads being available always.

You can remove all calls to addTestDevice("deviceid") when you're done testing and transitioning to the production phase.

like image 112
Nana Ghartey Avatar answered Oct 15 '22 19:10

Nana Ghartey


AdRequest adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR).addTestDevice("1915F1CFC0D22C6DBB4C8ED97B0CCBA1").build();

This is how you have to add your device id, you can get your device id from your logs in Android studio. and only for that device, test ads will be loaded.

like image 45
AnkitaKoladiya Avatar answered Oct 15 '22 18:10

AnkitaKoladiya


As per Google policy if you want to test ads then you need to define testing device id in your app or if you are not defining the testing device and test that app a lot of time in one device then Google will consider it as an illegal activity for ad revenue, So we need to define test device id in our debug apps.

Note: Do not click on ads even if you've added device ID in your app. That will be considered as a policy violation and your account may be blocked. You can only test the ads are visible in your app or not.

As mentioned by @AnkitaKoladiya's answer you can use this:

AdRequest adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build();

You can use it like below to avoid accidentally creating a signed APK with testing device ID:

AdRequest.Builder builder = new AdRequest.Builder();
if (BuildConfig.DEBUG) {
    builder.addTestDevice(AdRequest.DEVICE_ID_EMULATOR);
}
builder.build();

This will not include builder.addTestDevice(AdRequest.DEVICE_ID_EMULATOR); while building a signed APK. But it will include this in Dubug or test APK file. All device which installs APK with this line (builder.addTestDevice(AdRequest.DEVICE_ID_EMULATOR);) will be considered as a testing device. So you need to remove that when you'll making a signed APK for Playstore.

And if you don't find your device id, then first run your app without testing device ID in your testing device. After a successful build, you will see your device ID in Logcat.

like image 22
Dhaval Solanki Avatar answered Oct 15 '22 18:10

Dhaval Solanki