Kotlin/Java

The Colibri bindings for Kotlin/Java are built using CMake and Gradle. It can be used as AAR (Android Archive) or JAR (Java Archive).

💡 Quick Start: Check out the Example Android Apparrow-up-right for a complete working implementation!

Installation

The Colibri Kotlin/Java bindings are published to GitHub Packagesarrow-up-right and are publicly available without authentication.

Adding the Repository

Add the GitHub Packages repository to your project:

Groovy (build.gradle):

repositories {
    mavenCentral()
    maven {
        url = uri("https://maven.pkg.github.com/corpus-core/colibri-stateless")
    }
}

Kotlin DSL (build.gradle.kts):

repositories {
    mavenCentral()
    maven {
        url = uri("https://maven.pkg.github.com/corpus-core/colibri-stateless")
    }
}

Note: The packages are public and no authentication is required for downloading.

Versioning

The packages are automatically published with semantic versioning:

  • Release versions (e.g., 1.0.0, 1.2.3): Created from Git tags like v1.0.0

  • Snapshot versions (e.g., 1.0.0-SNAPSHOT): Built from the dev branch on every push

For production use, always pin to a specific release version. Use SNAPSHOT versions only for development and testing.

Usage

Java (JAR)

Add the JAR dependency to your build.gradle file:

Use it like this:

Kotlin

For Android (AAR)

For Android projects, use the AAR artifact that includes native libraries for all Android ABIs (armeabi-v7a, arm64-v8a, x86, x86_64):

For JVM/Server (JAR)

For server-side Kotlin or JVM projects, use the JAR artifact that includes native libraries for Linux, macOS (ARM64), and Windows:

Use it like this:

Example Android App

A complete working example is available in the example directoryarrow-up-right. This minimal Android app demonstrates:

  • Real-world usage: How to integrate Colibri in an Android application

  • RPC calls: Using eth_blockNumber to fetch the current Ethereum block number

  • Error handling: Proper exception handling for network and Colibri errors

  • Async operations: Using Kotlin coroutines for non-blocking RPC calls

  • UI integration: Updating Android UI components based on RPC results

Running the Example

The example app includes:

  • Simple UI with block number display and refresh button

  • Automatic block number fetching on startup

  • Error states and loading indicators

  • Public Ethereum RPC endpoint configuration (no API keys required)

Resources

Building

Make sure you have the Java SDK, Cmake and Swig installed.

JAR

While the CI is building the native libs for multiple platforms, you can build the JAR locally with:

AAR

Of course you need to install the Android SDK and NDK first.

Last updated