Why remove AdMob's addTestDevice() in production?

Viewed 2853

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?

4 Answers

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.

Related