airbnb/epoxy · warning · UnsupportedOperationException

Please use value or code explicitly

Error message

Please use value or code explicitly

What it means

ResourceValue deliberately disables toString() by throwing UnsupportedOperationException with 'Please use value or code explicitly'. Because a ResourceValue can represent either a literal value or a generated resource code (and the processor must not accidentally interpolate an ambiguous string), the class forces callers to choose value or code explicitly, e.g. via debugDetails().

Solutions

  1. Use .value when you want the literal resource value, or .code when you want the resource code reference
  2. Use debugDetails() for diagnostic output of the code representation
  3. Replace string-template interpolation of ResourceValue with an explicit property in your code

Example fix

// before
logger.info("Resolved $resourceValue")
// after
logger.info("Resolved ${resourceValue.debugDetails()}")
Defensive patterns

Strategy: type-guard

Validate before calling

// Never interpolate a ResourceValue; pick a representation first
if (resourceValue.isStringResource()) {
    log("string resource: ${resourceValue.code}")
} else {
    log("resource value: ${resourceValue.value}")
}

Try / catch

// Only as a last-resort diagnostic wrapper
val text = try { resourceValue.debugDetails() } catch (e: UnsupportedOperationException) { "<ResourceValue>" }

Prevention

When it happens

Trigger: Any code path (logging, string templates like "$resourceValue", error messages, assert messages, debugger evaluation) calls toString() on a ResourceValue instance from epoxy-processor's resourcescanning package.

Common situations: Developers hacking on the Epoxy processor add a log statement or exception message that interpolates a ResourceValue directly; or a processor crash report includes one in a message template.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of airbnb/epoxy@e45bd3a61f (2026-09-13). Data as JSON: /api/errors/2e89c36a5edf96a6. Report an issue: GitHub.

Appendix: source

Thrown at epoxy-processor/src/main/java/com/airbnb/epoxy/processor/resourcescanning/ResourceValue.kt:68

        if (this === other) return true
        if (other?.javaClass != javaClass) return false

        other as ResourceValue

        if (value != other.value) return false
        if (code != other.code) return false

        return true
    }

    override fun hashCode(): Int {
        var result = value
        result = 31 * result + code.hashCode()
        return result
    }

    override fun toString(): String {
        throw UnsupportedOperationException("Please use value or code explicitly")
    }

    fun debugDetails(): String = code.toString()

    fun isStringResource(): Boolean = resourceType == "string"
}

View on GitHub (pinned to e45bd3a61f)