Tencent/QMUI_Android · error · RuntimeException

You should config the exposure on parent($parent) for constr

Error message

You should config the exposure on parent($parent) for constraint effect.

What it means

ExposureEffect's constrained exposure logic requires the parent view to have been set up via the library's exposure config call, which stores a Boolean in R.id.qmui_exposure_config. If that tag is missing/false when doBeforeExpose runs for a constraint-type exposure, a RuntimeException is thrown telling you to configure exposure on the parent.

Source

Thrown at qmui/src/main/java/com/qmuiteam/qmui/exposure/ExposureEffect.kt:40

        target: View,
        container: ViewGroup,
        data: Exposure
    ){

    }
}

class ParentExposedRequestExposureEffect(val parent: ViewGroup) : ExposureEffect {
    override fun doBeforeExpose(
        target: View,
        container: ViewGroup,
        exposure: Exposure,
        lastExposure: Exposure?,
        type: ExposureType
    ): EffectResult {
        val isParentConfigSet = parent.getTag(R.id.qmui_exposure_config) as? Boolean ?: false
        if (!isParentConfigSet) {
            throw RuntimeException("You should config the exposure on parent($parent) for constraint effect.")
        }
        val holder = parent.getTag(R.id.qmui_exposure_holder) as? Runnable
        if (holder != null) {
            parent.removeCallbacks(holder)
            parent.setTag(R.id.qmui_exposure_holder, null)
            holder.run()
        }
        return if(parent.isInExposure()) EffectResult.pass else EffectResult.unHandled
    }
}


class RecyclerExposureEffect(
    val parent: ViewGroup,
    val safeDuration: Long = 500,
    val zombieDuration: Long = 2000
) : ExposureEffect {

View on GitHub (pinned to 026e7d4866)

Solutions

  1. Call the library's exposure config (e.g. ExposureEffect setup/config extension) on the direct parent view before enabling constraint exposure on the child.
  2. Verify parent.getTag(R.id.qmui_exposure_config) is true at the time of exposure.
  3. Re-apply the config after view hierarchy changes or adapter rebinds.

Example fix

// before
childView.exposure() // constraint effect, parent not configured -> throws
// after
parentView.configExposure() // sets qmui_exposure_config tag
childView.exposure()
Defensive patterns

Strategy: validation

Validate before calling

check(parent.getTag(R.id.qmui_exposure_config) == true) { "configure exposure on parent before constraint effect" }

Type guard

fun ViewGroup.hasExposureConfig(): Boolean = getTag(R.id.qmui_exposure_config) as? Boolean == true

Try / catch

try { childView.exposure() } catch (e: RuntimeException) { parentView.configExposure(); childView.exposure() }

Prevention

When it happens

Trigger: Using constraint-based exposure on a child view without first calling the exposure config/setup API on its direct parent view, so the qmui_exposure_config tag is unset.

Common situations: Adding exposure tracking to a child inside a container but only configuring the child; restructuring view hierarchies so the configured parent is no longer the direct parent; forgetting setup after refactor.

Understand the failure class

Background: "X is required", "must be set", "cannot be empty": the missing-required-config error family, from Vertex AI project/location to WeChat keys — this error's family across 18 libraries.

Related errors


AI-assisted analysis of Tencent/QMUI_Android@026e7d4866 (2026-09-06). Data as JSON: /api/errors/1d1273c706281bfe. Report an issue: GitHub.