Reputation: 163
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?
Upvotes: 16
Views: 3160
Reputation: 8931
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.
Upvotes: 7
Reputation: 1170
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!!!
Upvotes: 17
Reputation: 2148
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.
Upvotes: -10
Reputation: 149
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.
Upvotes: 2