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(AbstractReplicatorConfiguration.java:56)
        at com.couchbase.lite.ReplicatorConfiguration.<init>(ReplicatorConfiguration.java:85)
        at com.couchbase.lite.ConfigurationFactoriesKt.create(ConfigurationFactories.kt:47)
        at com.couchbase.lite.ConfigurationFactoriesKt.create$default(ConfigurationFactories.kt:29)

Caused by AbstractReplicatorConfiguration.java:

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.

Has there been any movement on this issue? Our team would also like to upgrade to OkHttp 5.x and this is a blocker for us doing that as well.

Couchbase Lite 3.2.4 was released in June 2025. I think it is at okhttp 4.12. If you are using that, and still have an issue, please start a new post. Thanks.

I opened a ticket - Jira
Please refer to the ticket in future inquiries.