java.lang.NoClassDefFoundError: Failed resolution of: Lokhttp3/internal/Util; Because of upgrade to okhttp 5.x

Using Couchbase Lite 3.0.5 Enterprise:

java.lang.NoClassDefFoundError: Failed resolution of: Lokhttp3/internal/Util;
        at com.couchbase.lite.AbstractReplicatorConfiguration.verifyHeartbeat(
        at com.couchbase.lite.ReplicatorConfiguration.<init>(
        at com.couchbase.lite.ConfigurationFactoriesKt.create(ConfigurationFactories.kt:47)
        at com.couchbase.lite.ConfigurationFactoriesKt.create$default(ConfigurationFactories.kt:29)

Caused by

protected static int verifyHeartbeat(int heartbeat) {
    Util.checkDuration("heartbeat", Preconditions.assertNotNegative(heartbeat, "heartbeat"), TimeUnit.SECONDS);
    return heartbeat;

Because you are using this method from okhttp 4.10.0:

fun checkDuration(name: String, duration: Long, unit: TimeUnit?): Int {
  check(duration >= 0L) { "$name < 0" }
  check(unit != null) { "unit == null" }
  val millis = unit.toMillis(duration)
  require(millis <= Integer.MAX_VALUE) { "$name too large." }
  require(millis != 0L || duration <= 0L) { "$name too small." }
  return millis.toInt()

Which is moved on okhttp 5.x and now the Couchbase Lite library cannot reference it anymore

You are correct about everything except the version of OkHttp that we are using. We are using okhttp 3.14.7. We are likely to update in the next year or so.

Wouldn’t it be possible for the Couchbase library to avoid using these internal functions from another third party library?

Not “these”, “this”. And not without duplicating it… Since this method is ground truth, duplicating it seemed to us the greater of two evils.