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.
- AIDL-like IPC without maintaining
.aidlfiles - Kotlin interface-centric workflow
- Works with suspend functions
- Handles common Android IPC types, collections, parcelables, and nested binder interfaces
- Apply KSP in your module.
plugins { id("com.google.devtools.ksp") version "<ksp-version>" } - Add the compiler and runtime dependencies.
dependencies { ksp("io.github.goooler.kaidl:kaidl-compiler:<latest>") implementation("io.github.goooler.kaidl:kaidl-runtime:<latest>") } - Sync and build.
./gradlew build
Notes:
- Use a KSP version that matches your Kotlin version.
- If generated symbols are not visible in IDE, follow KSP guidance: https://github.com/google/ksp#make-ide-aware-of-generated-code
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)- 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
See the example interfaces and instrumentation tests:
For contribution workflow, see CONTRIBUTING.md.