You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

UMP测试对话框始终显示问题咨询(未发布正式对话框)

关于AdMob UMP始终显示测试对话框的问题排查与解决办法

问题概述

已严格遵循AdMob官方文档集成UMP隐私对话框,但始终显示测试版对话框,即使未在AdMob后台发布正式对话框。已使用生产证书签名APK并手动安装到设备测试,问题仍存在,担心上线后用户看到测试对话框。

附测试对话框截图:
测试UMP对话框

使用的核心代码:

class MainActivity : AppCompatActivity() {
  private lateinit var consentInformation: ConsentInformation
  private var isMobileAdsInitializeCalled = AtomicBoolean(false)
  
  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)

    val params = ConsentRequestParameters
        .Builder()
        .setTagForUnderAgeOfConsent(false)
        .build()

    consentInformation = UserMessagingPlatform.getConsentInformation(this)
    consentInformation.requestConsentInfoUpdate(
        this,
        params,
        ConsentInformation.OnConsentInfoUpdateSuccessListener {
          UserMessagingPlatform.loadAndShowConsentFormIfRequired(
            this@MainActivity,
            ConsentForm.OnConsentFormDismissedListener { loadAndShowError ->
              Log.w(TAG, String.format("%s: %s", loadAndShowError.errorCode(), loadAndShowError.message()))
              if (consentInformation.canRequestAds) {
                initializeMobileAdsSdk()
              }
            }
          )
        },
        ConsentInformation.OnConsentInfoUpdateFailureListener { requestConsentError ->
          Log.w(TAG, String.format("%s: %s", requestConsentError.errorCode(), requestConsentError.message()))
        })
    
    if (consentInformation.canRequestAds) {
      initializeMobileAdsSdk()
    }
  }
  
  private fun initializeMobileAdsSdk() {
    if (isMobileAdsInitializeCalled.get()) {
      return
    }
    isMobileAdsInitializeCalled.set(true)
    MobileAds.initialize(this)
  }
}

可能原因

  • 未在AdMob后台完成并发布正式的隐私许可配置
  • 设备缓存了旧的测试状态未清除
  • 应用签名与AdMob后台配置的生产签名不匹配
  • 设备被标记为AdMob测试设备
  • 代码中隐含开启了测试模式

解决步骤

1. 完成并发布AdMob后台的正式隐私配置

进入AdMob后台的「隐私与消息」板块,创建并配置符合地区合规要求的隐私许可表单(包含适用地区、广告合作伙伴列表等),确认配置无误后点击发布。注意:配置发布后需等待1-2小时才能全局生效,请勿立即测试。

2. 清除设备上的应用缓存与数据

卸载当前测试应用,或在设备应用设置中清除该应用的缓存和数据,避免旧的测试状态被缓存影响新的生产包测试。

3. 验证生产签名的正确性

确认打包使用的是生产环境的keystore文件,而非调试keystore。可通过以下命令查看证书指纹,并确保与AdMob后台添加的应用签名指纹完全一致:

keytool -list -v -keystore your-production-keystore.jks

4. 移除AdMob后台的测试设备标记

如果之前在AdMob后台添加过测试设备ID,暂时移除该标记,确保测试设备被识别为生产环境设备。

5. 检查代码中的测试模式配置

确认代码中未主动设置测试相关参数,例如:

// 禁止添加此类强制测试地区的代码
params.setDebugGeography(DebugGeography.DEBUG_GEOGRAPHY_EEA)

代码优化建议

在Consent信息更新成功的回调中添加日志,便于排查UMP的状态:

ConsentInformation.OnConsentInfoUpdateSuccessListener {
    Log.d(TAG, "Consent状态: ${consentInformation.consentStatus}")
    Log.d(TAG, "可请求广告: ${consentInformation.canRequestAds}")
    Log.d(TAG, "是否有可用许可表单: ${consentInformation.isConsentFormAvailable}")
    UserMessagingPlatform.loadAndShowConsentFormIfRequired(...)
}

通过日志可确认UMP是否正确获取到正式配置的状态。

补充说明

UMP测试对话框仅在以下场景显示:

  • 应用处于调试模式(未使用生产签名)
  • 设备被标记为AdMob测试设备
  • 未发布正式隐私配置(上线前需确保配置已发布,上线后会自动切换到正式表单)
  • 代码中强制开启了测试地理区域

内容的提问来源于stack exchange,提问作者NullPointerException

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.06 13:53:27