Google Ads: Test Device Registration
It is critical to register your devices as test devices whenever you are developing or testing an app with Google Ads (AdMob).
https://developers.google.com/admob/android/test-ads#enable_test_devices
1. Why is this necessary?
- Prevent Account Suspension: Google has strict policies against "Invalid Traffic." If you or your developers accidentally click on a live ad while testing, Google may flag it as fraud and suspend your AdMob account permanently.
- Safe Testing: Test devices always receive "Test Ads," which are safe to click and don't affect your actual ad revenue or analytics.
- No Inventory Issues: Test ads always load, even if there is no real ad inventory available in your region.
2. Where is it done in the code?
The registration is handled in the free version of the app within the ad initialization logic.
- File Path:
app/src/free/java/com/example/iptv/AdInitializer.kt - Function:
initializeAds(context: Context)
3. Which devices are registered?
The current implementation registers the following devices:
- The Android Emulator: Automatically identified by
AdRequest.DEVICE_ID_EMULATOR. - Your Physical Device (OnePlus Nord CE 2): Manually registered using its hashed ID:
B78B2E287CB799F98207B1E9FC68C39C.
Code Snippet
// Snippet from AdInitializer.kt
val testDeviceIds = listOf(
AdRequest.DEVICE_ID_EMULATOR,
"B78B2E287CB799F98207B1E9FC68C39C"
)