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

24 views
Skip to first unread message

Liran Barsisa

unread,
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)) }
MobileAds.setRequestConfiguration(RequestConfiguration.Builder().setTestDeviceIds(deviceIds).build())
Log.d("AppLog", "success being test device? ${AdRequest.Builder().build().isTestDevice(context)}")

    @SuppressLint("HardwareIds")
    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:
https://developers.google.com/admob/android/test-ads#add_your_test_device_programmatically

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

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

Hi,

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"

Thanks,
 
Google Logo Mobile Ads SDK Team

 

Reply all
Reply to author
Forward
0 new messages