How to add test device programmatically for AdMob?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By subtree

Hello everyone, I want to add my device as a test device to test mediation. I tried to add the test device through AdMob UI: Set up a test device - Google AdMob Help but I never got any test ads on my device. Every time I got error 3 which is Ad failed to load.

Other way is to add this line below as mentioned on this link: Enabling test ads  |  Android  |  Google for Developers

RequestConfiguration.Builder.setTestDeviceIds(Arrays.asList(“33BE2250B43518CCD1”))
But I am not understanding where should I add this line? In which file should I add this line?

Thanks for your help.