Skip to content

Goooler/kaidl

 
 

Repository files navigation

kaidl

Maven Central

Kotlin-first Binder interface generation for Android.

kaidl gives you an AIDL-like workflow using plain Kotlin interfaces and KSP. You define an interface once, annotate it, and use generated proxy/stub glue with strongly-typed APIs.

Why kaidl

  • AIDL-like IPC without maintaining .aidl files
  • Kotlin interface-centric workflow
  • Works with suspend functions
  • Handles common Android IPC types, collections, parcelables, and nested binder interfaces

Installation

  1. Apply KSP in your module.
    plugins {
      id("com.google.devtools.ksp") version "<ksp-version>"
    }
  2. Add the compiler and runtime dependencies.
    dependencies {
      ksp("io.github.goooler.kaidl:kaidl-compiler:<latest>")
      implementation("io.github.goooler.kaidl:kaidl-runtime:<latest>")
    }
  3. Sync and build.
    ./gradlew build

Notes:

Quick Start

Define an interface:

import com.github.kr328.kaidl.BinderInterface

@BinderInterface
interface EchoService {
  fun echoInt(value: Int): Int
}

Use generated helpers in service/client code:

class EchoImpl : EchoService {
  override fun echoInt(value: Int): Int = value
}

val localImpl = EchoImpl()
val binder = localImpl.wrap()
val remote = binder.unwrap(EchoService::class)

val result = remote.echoInt(42)

Supported Types

  • Primitives: Int, Long, Boolean, Float, Double, String, Byte, Char
  • Primitive arrays: BooleanArray, ByteArray, CharArray, DoubleArray, FloatArray, IntArray, LongArray
  • Android framework types: Bundle, IBinder, SparseBooleanArray
  • Date types: java.util.Date (epoch millis)
  • UUID types: java.util.UUID, kotlin.uuid.Uuid (string encoding)
  • Generic containers: List<T>, Array<T>, Map<K, V>, Set<T>, Pair<A, B>
  • Parcelables: custom Parcelable
  • Binder interfaces: other interfaces annotated with @BinderInterface
  • Nullable variants where applicable
  • Suspend functions

Example Project

See the example interfaces and instrumentation tests:

For contribution workflow, see CONTRIBUTING.md.

Credits

About

Generate AIDL-like android binder interface with Kotlin

Resources

License

Contributing

Stars

Watchers

Forks

Contributors

Languages

  • Kotlin 100.0%