Bug: AdRequest.isTestDevice returns true, yet ad-inspector says I should set it as test device

Skip to first unread message

Liran Barsisa

Sep 21, 2023, 4:10:27 AMSep 21
to Google Mobile Ads SDK Developers
Running on emulator and on real device, I initialized Admob as such for testing ads:

Log.d("AppLog", "adding current device/emulator as test device...")
val deviceIds = arrayListOf(AdRequest.DEVICE_ID_EMULATOR)
getDeviceIdForAdMobTestAds(context)?.let { deviceIds.add(it.uppercase(Locale.US)) }
Log.d("AppLog", "success being test device? ${AdRequest.Builder().build().isTestDevice(context)}")

    private fun getDeviceIdForAdMobTestAds(context: Application): String? {
        val md5 = Settings.Secure.getString(context.contentResolver, Settings.Secure.ANDROID_ID)
        try {
            val md = MessageDigest.getInstance("MD5")
            val array = md.digest(md5.toByteArray())
            val sb = StringBuilder()
            for (i in array.indices) sb.append(Integer.toHexString(array[i].toInt() and 0xFF or 0x100).substring(1, 3))
            return sb.toString()
        } catch (_: NoSuchAlgorithmException) {
        return null

It says it is indeed a test device now, as shown that I should check here:

However, when I try to start the ad-inspector , I get this error:

"Code": 2,
"Message": "Ad inspector cannot be opened because the device is not in test mode. See https:\/\/developers.google.com\/admob\/android\/test-ads#enable_test_devices for more information.",
"Domain": "com.google.android.gms.ads",
"Cause": "null"

Please fix this.
Even the link doesn't show correctly in the error.

Gradle config:
classpath 'com.google.gms:google-services:4.4.0'
implementation 'com.google.android.gms:play-services-ads:22.4.0'

Mobile Ads SDK Forum Advisor

Sep 22, 2023, 6:51:27 AMSep 22
to lbl...@gmail.com, google-adm...@googlegroups.com


Thank you for contacting the Mobile Ads SDK Support team.

Upon reviewing your concern, I understand that you are facing an issue with the Ad inspector. Kindly provide the below information for further investigation:

  • app ID 
  • ad unit ID
This message is in relation to case "ref:_00D1U1174p._5004Q2p048b:ref"

Google Logo Mobile Ads SDK Team


Reply all
Reply to author
0 new messages