15

On this page

https://developers.google.com/admob/android/test-ads#add_your_test_device

it says

Note: Be sure to remove the code that sets these test devices before you release your app.

Can anyone explain why? Why can't I leave the line of code that sends my particular device test ads no matter what? Doesn't this help prevent me from breaking AdMob's rules about developers not accidentally giving themselves false impressions or clicks?

user8298723
  • 153
  • 1
  • 4

4 Answers4

15

I don't remove the testdevice directive in any of my apps. This is for my own protection - when I download my own apps from the App Store I still only want to see advertising marked as test advertising on my own devices. I have had no detrimental effects from leaving the lines of code in and most importantly it protects me from Google banning me from Admob if I inadvertently click on one of these ads. Clicking on your own non-testAd advertising that is displayed inside your own apps is particularly frowned upon by Admob. Rest assured that all other users (those not inside the testdevice directive) still see real advertising not marked as testAds.

Edit June 2019 - I still do this 2 years later. In the latest Admob API's you will see real advertising for real companies, but it will have a small "TestAd" text over the top of it. This signifies that the ad is marked as a test ad, and you won't be penalised by Admob for clicking on it. Never click on your own ads without the TestAd text!!!

Peter Smith
  • 1,150
  • 8
  • 11
  • HI, dose this test ad classification stop me from earning from my ads shown in my app?I am pretty unsure and unclear about this! please clarify about your monetization @Peter Smith – Achy97 Jun 28 '19 at 17:28
  • I'm really confused. Google says to remove it as far as I remember but I don't quite see why. Is this still standing - I mean, not removing does no damage? – José Feb 03 '20 at 05:50
  • Should we remove the code or not? Please reply in yes or no format – Pokhraj Sah Aug 16 '20 at 04:41
6

The reason the docs say to remove test device in production is there is a low-risk security issue whereby if you leave that code in your app, someone could theoretically deobfuscate the APK, get your hash, and detect you as the author of the app if they put some malware into a different app that you have on your device. Removing the test device ID from the app eliminates this risk.

If you're ok to assume that risk, it's better to leave the test device ID in the app, so that you can continue to click ads from that device in production without worrying about generating invalid traffic.

Eric Leichtenschlag
  • 8,881
  • 1
  • 28
  • 28
2

There is no exact reason why that line for using test devices for ads should be removed. As a general rule when releasing apps, all traces for testing and debugging should be remove in order not to interfere with the release version of your app and in order to avoid any loop holes in your app. With that line in your code, that means if someone is using a device to test your app with the same test id, you won't get anything from admob because it is using a test device id rather than an actual device id. What I usually do is just comment it out for easy testing later on when modifying my app for another version release.

zhack
  • 149
  • 8
  • It is possible for other devices to have the same device ID that I do? – user8298723 Jul 13 '17 at 00:58
  • no, but anyone can mimic a test device ID if he is using an emulator to test your app or a rooted android device. I used to do this to test an old app in an emulator and see if I get the test ads. – zhack Jul 13 '17 at 01:04
  • How do I then give myself the ad-free version of the app without seeing real ads, since the upgrade to no-ad version is an in-app purchase? (seeing or clicking your own ads is against AdMob policy) – user8298723 Jul 13 '17 at 01:12
  • @user8298723 as long as you dont click them, there is no problem – Martin De Simone Jul 13 '17 at 01:30
  • @MartinDeSimone So impressions (i.e. just seeing them) briefly won't count against me? I can install my app, be able to see the live ads, but give myself a promo code and upgrade to premium version with no ads, and I won't get my AdMob account revoked, as long as I don't click the live ad? – user8298723 Jul 13 '17 at 01:33
  • @user8298723 That is right, the only problem is if you click them – Martin De Simone Jul 13 '17 at 01:34
  • @MartinDeSimone But it is advised to remove any test-device code (i.e. my test-device ID string) from the code since it can be replicated by anyone who has rooted their phone or using an emulator? – user8298723 Jul 13 '17 at 01:35
  • @user8298723 see my answer – Martin De Simone Jul 13 '17 at 01:37
  • 2
    Google usually prohibits even displaying the live ads for testing. It's everywhere in the documentation. However, google knows that devs will not pay heed to its advice and hence ignores (or fails to detect) when such ads are shown for testing. However, just because devs do not get caught does not mean that they are not committing a violation. Viewing, or even merely loading, a real ad messes up Google's data (albeit at a micro level) so I would suggest to always be on the safe side. – Usman May 26 '18 at 16:11
-10

If you have the addTestDevice() in production, user wont be able to see real ads, no matter what is the device id passed to the method.

You should only use this code in testing.

Martin De Simone
  • 2,108
  • 3
  • 16
  • 30