Files
2026-02-08 11:20:43 -10:00

4.5 KiB
Vendored

Integrate Kotlin DataFrame into your Android app using the standard JVM dependency and simple Gradle configuration. Set up Kotlin DataFrame in Android — configure it easily using Gradle and start working with structured data. How to use Kotlin DataFrame in your Android project with Gradle setup and compiler plugin support.

See an Android project example.

Kotlin DataFrame doesn't provide a dedicated Android artifact yet, but you can add the Kotlin DataFrame JVM dependency to your Android project with minimal configuration:

dependencies {
    // Core Kotlin DataFrame API, CSV and JSON IO.
    // See custom Gradle setup:
    // https://kotlin.github.io/dataframe/setupcustomgradle.html
    implementation("org.jetbrains.kotlinx:dataframe-core:%dataFrameVersion%")
    implementation("org.jetbrains.kotlinx:dataframe-json:%dataFrameVersion%")
    implementation("org.jetbrains.kotlinx:dataframe-csv:%dataFrameVersion%")
    // You can add any additional IO modules you like, except for 'dataframe-arrow'.
    // Apache Arrow is not supported well on Android.
}

android {
    defaultConfig {
        minSdk = 21
    }
    // Requires Java 8 or higher
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = "1.8"
    }
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> { 
    kotlinOptions.jvmTarget = "1.8" 
}
dependencies {
    // Core Kotlin DataFrame API, CSV and JSON IO.
    // See custom Gradle setup:
    // https://kotlin.github.io/dataframe/setupcustomgradle.html
    implementation 'org.jetbrains.kotlinx:dataframe-core:%dataFrameVersion%'
    implementation 'org.jetbrains.kotlinx:dataframe-json:%dataFrameVersion%'
    implementation 'org.jetbrains.kotlinx:dataframe-csv:%dataFrameVersion%'
    // You can add any additional IO modules you like, except for 'dataframe-arrow'.
    // Apache Arrow is not supported well on Android.
}

android {
    defaultConfig {
        minSdk 21
    }
    // Requires Java 8 or higher
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = "1.8"
    }
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach { 
    kotlinOptions.jvmTarget = "1.8"
}

This setup adds the Kotlin DataFrame core as well as a subset of the IO modules (excluding experimental ones). For flexible configuration, see Custom configuration.

Kotlin DataFrame Compiler Plugin

Kotlin DataFrame Compiler Plugin enables automatic generation of extension properties and updates data schemas on-the-fly in Android projects, making development with Kotlin DataFrame faster, more convenient, and fully type- and name-safe.

Requires Kotlin 2.2.20-Beta1 or higher.
{ style = "note" }

To enable the plugin in your Gradle project, add it to the plugins section:

plugins {
    kotlin("plugin.dataframe") version "%compilerPluginKotlinVersion%"
}
plugins {
    id 'org.jetbrains.kotlin.plugin.dataframe' version '%compilerPluginKotlinVersion%'
}

Due to this issue, incremental compilation must be disabled for now. Add the following line to your gradle.properties file:

kotlin.incremental=false

Next Steps