admob_test_device_ids

534 views
Skip to first unread message

swarajg...@gmail.com

unread,
Sep 4, 2015, 11:08:22 AM9/4/15
to Google Mobile Ads SDK Developers
What is admob_test_device_ids how to get it

Kunal Verma

unread,
Sep 4, 2015, 11:32:19 AM9/4/15
to google-adm...@googlegroups.com
Admob test device id is very useful. It is unique for every device. And when included in the code for an adrequest, that particular device will show test ads for that adrequest. Test ads are recommended while developing as you can click them without worrying for the purpose of testing.
Get it from the logcat while sending an adrequest when running app on that device for the first time.

On Fri, 4 Sep 2015 at 8:38 PM, <swarajg...@gmail.com> wrote:
What is admob_test_device_ids how to get it

--

---
You received this message because you are subscribed to the Google Groups "Google Mobile Ads SDK Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-admob-ads...@googlegroups.com.
To post to this group, send email to google-adm...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Vu Chau (MobileAds SDK Team)

unread,
Sep 4, 2015, 11:55:41 AM9/4/15
to Google Mobile Ads SDK Developers
Hi there,

Kunal did a good job explaining what a test device ID is.  I am just going to chime in with a screenshot so you know exactly where to locate your device ID.

Cheers,

Vu Chau
Mobile Ads SDK Team

On Friday, September 4, 2015 at 11:32:19 AM UTC-4, Kunal Verma wrote:
Admob test device id is very useful. It is unique for every device. And when included in the code for an adrequest, that particular device will show test ads for that adrequest. Test ads are recommended while developing as you can click them without worrying for the purpose of testing.
Get it from the logcat while sending an adrequest when running app on that device for the first time.

On Fri, 4 Sep 2015 at 8:38 PM, <swarajg...@gmail.com> wrote:
What is admob_test_device_ids how to get it

--

---
You received this message because you are subscribed to the Google Groups "Google Mobile Ads SDK Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-admob-ads-sdk+unsub...@googlegroups.com.
To post to this group, send email to google-admob-ads-sdk@googlegroups.com.
TestDeviceID.jpg

Zol Heyman

unread,
Sep 4, 2015, 10:57:33 PM9/4/15
to Google Mobile Ads SDK Developers
I tried debugging with my MotoX phone via USB and just running the app on its own and could not get this to work with interstitial ads, even after contacting the support team.  They told me my code looked correct, but don't worry.  As long as I didn't click on the ads, it would be ok for testing.  I wasn't taking any chances so I used the code below to check if the current device ID was mine.  If it was, I changed the ad unit id to the test ad unit id.  They didn't seem very interested in fixing this bug.

InterstitialAd admobAd = new InterstitialAd(context);
String android_id = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
String deviceId = md5(android_id).toUpperCase();
String unitId = MY_UNIT_ID;
if (deviceId.equals(MY_DEVICE_ID)) {
    // Use the AdMob Interstitial Test Unit ID
unitId = context.getResources().getString("ca-app-pub-3940256099942544/1033173712");
}
admobAd.setAdUnitId(unitId);

// Here's the md5 method
private String md5(String s) {
try {
// Create MD5 Hash
MessageDigest digest = java.security.MessageDigest.getInstance("MD5");
digest.update(s.getBytes());
byte messageDigest[] = digest.digest();

// Create Hex String
StringBuffer hexString = new StringBuffer();
for (int i=0; i<messageDigest.length; i++)
hexString.append(Integer.toHexString(0xFF & messageDigest[i]));
return hexString.toString();

} catch (Exception e) {
e.printStackTrace();
}
return "";
}

Vu Chau (MobileAds SDK Team)

unread,
Sep 8, 2015, 11:38:23 AM9/8/15
to Google Mobile Ads SDK Developers
Hi Zol,

You do not have to check if the device is yours (via an if statement) before displaying test ads.  As noted in the log, simply append your device ID to the request builder, and your device will be getting test ads (currently there are three ways to get test ads: via the emulator, by using the test ad unit ID, and by using the test device ID).

Vu Chau
Mobile Ads SDK Team

Zol Heyman

unread,
Sep 8, 2015, 12:12:38 PM9/8/15
to Google Mobile Ads SDK Developers
Perhaps you missed my comment about this not working,  I tried using Builder.addTestDevice(deviceId) like you describe, but this did not work for me with Interstitial ads in both USB debugging and with normal phone usage.  The tech support team saw nothing wrong with my code and just told me to ignore it.  They said I would not be penalized.  I believe this is a bug.  So I use the workaround I described in my previous post.

Zol

Vu Chau (MobileAds SDK Team)

unread,
Sep 8, 2015, 4:55:13 PM9/8/15
to Google Mobile Ads SDK Developers
Hi Zol,

I tried requesting test interstitial ads on my device using Builder.addTestDevice(deviceId), and it worked just fine.  I did not see any problems.

Do you get back any error code in the log?  What do you see when you said it is not working?

Vu Chau
Mobile Ads SDK Team

Zol Heyman

unread,
Sep 9, 2015, 12:58:31 AM9/9/15
to Google Mobile Ads SDK Developers
No there were no errors.  I just got real ads instead of test ads.  And the AdRequest.isTestDevice(context) method called on the AdRequest created by the AdRequest.Builder returned false as well.  So the addTestDevice(deviceId) did not seem to do anything.

Vu Chau (MobileAds SDK Team)

unread,
Sep 9, 2015, 5:01:23 PM9/9/15
to Google Mobile Ads SDK Developers
Hi Zol,

Could you confirm if isTestDevice() returns false for other devices as well?  I am suspecting that there might be more than one ad request in your code, with the first one already requesting live ads.  Therefore, the second call that uses the test device ID is ignored.  Could you verify if this is the case?

Vu Chau
Mobile Ads SDK Team

Zol Heyman

unread,
Sep 9, 2015, 10:14:57 PM9/9/15
to Google Mobile Ads SDK Developers
I tested multiple devices and got the same result.  I only have one class that manages ad requests.  All requests for ads via the AdRequest.Builder use the same method which always does addTestDevice(myDeviceId).  It's the only place in the code that creates ad requests.

Vu Chau (MobileAds SDK Team)

unread,
Sep 10, 2015, 2:07:33 PM9/10/15
to Google Mobile Ads SDK Developers
Hi Zol,

Would you mind sending us your project so we can determine if the issue is reproducible here on our end?  There should be an option via the forum to reply privately to me.  Or feel free to reach out and I'll contact you offline.

Vu Chau
Mobile Ads SDK Team

Zol Heyman

unread,
Sep 11, 2015, 10:03:14 PM9/11/15
to Google Mobile Ads SDK Developers
I found the problem.  The md5() method code I found on the internet created a device id that was exactly the same as the one from the logcat except for one character.  That's the one I was using in addTestDevice(). Once I fixed the device id, everything worked ok.  Sorry for taking up your time.

Zol

Vu Chau (MobileAds SDK Team)

unread,
Sep 14, 2015, 11:11:44 AM9/14/15
to Google Mobile Ads SDK Developers
Hi Zol,

I'm glad to hear the problem has been resolved!  Do let us know if you need anything else.

Vu Chau
Mobile Ads SDK Team

Reply all
Reply to author
Forward
0 new messages