Why remove AdMob's addTestDevice() in production?

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!!!


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.


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.