Differences from Java SDK

Kotbase's API aligns with the Couchbase Lite Java and Android KTX SDKs. Migrating existing Kotlin code can be as straightforward as changing the import package from com.couchbase.lite to kotbase, with some exceptions:

  • Java callback functional interfaces are implemented as Kotlin function types.
  • File, URL, and URI APIs are represented as strings.
  • Date APIs use kotlinx-datetime's Instant.
  • InputStream APIs use kotlinx-io's Source.
  • Executor APIs use Kotlin's CoroutineContext.
  • Certificate APIs are available as raw ByteArrays or in platform-specific code.
  • There's no need to explicitly call CouchbaseLite.init(). Initialization functions can still be called with custom parameters in JVM and Android platform code.
  • Efforts have been made to detect and throw Kotlin exceptions for common error conditions, but NSError may still leak through on Apple platforms. Please report any occurrences that may deserve addressing.
  • Some deprecated APIs are omitted.
  • While not available in the Java SDK, as Java doesn't support operator overloading, Fragment subscript APIs are available in Kotbase, similar to Swift, Objective-C, and .NET.