1
1
[ // ] : # ( title: Setup Kotlin DataFrame on Android )
2
2
3
- ## Gradle
3
+ <web-summary >
4
+ Integrate Kotlin DataFrame into your Android app using the standard JVM dependency and simple Gradle configuration.
5
+ </web-summary >
4
6
5
- The Kotlin DataFrame library is published to Maven Central,
6
- so you can add the following line to your Kotlin DSL
7
- buildscript to depend on it:
7
+ < card-summary >
8
+ Set up Kotlin DataFrame in Android — configure it easily using Gradle and start working with structured data.
9
+ </ card-summary >
8
10
9
- ### General configuration
11
+ <link-summary >
12
+ How to use Kotlin DataFrame in your Android project with Gradle setup and compiler plugin support.
13
+ </link-summary >
14
+
15
+ > See an [ Android project example] ( https://github.com/Kotlin/dataframe/tree/master/examples/android-example ) .
16
+
17
+ Kotlin DataFrame doesn't provide a dedicated Android artifact yet,
18
+ but you can add the Kotlin DataFrame JVM dependency to your Android project with minimal configuration:
10
19
11
20
<tabs >
12
21
<tab title =" Kotlin DSL " >
13
22
14
23
``` kotlin
15
- plugins {
16
- id(" org.jetbrains.kotlinx.dataframe" ) version " %dataFrameVersion%"
17
- }
18
-
19
24
dependencies {
20
25
implementation(" org.jetbrains.kotlinx:dataframe:%dataFrameVersion%" )
21
26
}
22
27
23
- // Below only applies to Android projects
24
28
android {
29
+ // Requires Android 0+, i.e. SDK version 26 or higher.
25
30
defaultConfig {
26
- minSdk = 26 // Android O+
31
+ minSdk = 26
27
32
}
33
+ // Requires Java 8 or higher
28
34
compileOptions {
29
35
sourceCompatibility = JavaVersion .VERSION_1_8
30
36
targetCompatibility = JavaVersion .VERSION_1_8
@@ -62,19 +68,16 @@ tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
62
68
<tab title =" Groovy DSL " >
63
69
64
70
``` groovy
65
- plugins {
66
- id "org.jetbrains.kotlinx.dataframe" version "%dataFrameVersion%"
67
- }
68
-
69
71
dependencies {
70
72
implementation 'org.jetbrains.kotlinx:dataframe:%dataFrameVersion%'
71
73
}
72
74
73
- // Below only applies to Android projects
74
75
android {
76
+ // Requires Android 0+, i.e. SDK version 26 or higher.
75
77
defaultConfig {
76
- minSdk 26 // Android O+
78
+ minSdk 26
77
79
}
80
+ // Requires Java 8 or higher
78
81
compileOptions {
79
82
sourceCompatibility JavaVersion.VERSION_1_8
80
83
targetCompatibility JavaVersion.VERSION_1_8
@@ -91,6 +94,7 @@ android {
91
94
"META-INF/LICENSE.md",
92
95
"META-INF/NOTICE.md",
93
96
"META-INF/LGPL-3.0.txt",
97
+ "META-INF/thirdparty-LICENSE",
94
98
]
95
99
excludes += [
96
100
"META-INF/kotlin-jupyter-libraries/libraries.json",
@@ -107,101 +111,32 @@ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
107
111
```
108
112
109
113
</tab >
110
-
111
114
</tabs >
112
115
113
- Note that it's better to use the same version for a library and plugin to avoid unpredictable errors.
114
- After plugin configuration, you can try it out, for [ example] ( schemasGradle.md#annotation-processing ) .
116
+ This setup adds the [ general Kotlin DataFrame dependency] ( Modules.md#dataframe-general ) ,
117
+ which includes the [ core API and implementation] ( Modules.md#dataframe-core )
118
+ as well as all [ IO modules] ( Modules.md#io-modules )
119
+ (excluding [ experimental ones] ( Modules.md#experimental-modules ) ).
120
+ For flexible configuration, see [ Custom configuration] ( SetupCustomGradle.md ) .
115
121
116
- ### Custom configuration
122
+ ## Kotlin DataFrame Compiler Plugin
117
123
118
- If you want to avoid adding unnecessary dependencies, you can choose from the following artifacts:
124
+ [ Kotlin DataFrame Compiler Plugin] ( Compiler-Plugin.md ) enables automatic generation
125
+ of [ extension properties] ( extensionPropertiesApi.md ) and updates [ data schemas] ( schemas.md )
126
+ on-the-fly in Android projects, making development with Kotlin DataFrame
127
+ faster, more convenient, and fully type- and name-safe.
119
128
120
- < tabs >
121
- < tab title = " Kotlin DSL " >
129
+ > Requires Kotlin 2.2.20-Beta1 or higher.
130
+ > { style = "note" }
122
131
123
- ``` kotlin
124
- dependencies {
125
- // Artifact containing all APIs and implementations
126
- implementation(" org.jetbrains.kotlinx:dataframe-core:%dataFrameVersion%" )
127
- // Optional formats support
128
- implementation(" org.jetbrains.kotlinx:dataframe-json:%dataFrameVersion%" )
129
- implementation(" org.jetbrains.kotlinx:dataframe-csv:%dataFrameVersion%" )
130
- implementation(" org.jetbrains.kotlinx:dataframe-excel:%dataFrameVersion%" )
131
- implementation(" org.jetbrains.kotlinx:dataframe-jdbc:%dataFrameVersion%" )
132
- implementation(" org.jetbrains.kotlinx:dataframe-arrow:%dataFrameVersion%" )
133
-
134
- // experimental
135
- implementation(" org.jetbrains.kotlinx:dataframe-openapi:%dataFrameVersion%" )
136
-
137
- // experimental
138
- // This artifact is only needed to directly call functions that generate @DataSchema code from OpenAPI specifications
139
- // It's used by Gradle and KSP plugins internally.
140
- // Your project needs dataframe-openapi to use generated code
141
- implementation(" org.jetbrains.kotlinx:dataframe-openapi-generator:%dataFrameVersion%" )
142
- }
143
- ```
144
-
145
- </tab >
146
-
147
- <tab title =" Groovy DSL " >
148
-
149
- ``` groovy
150
- dependencies {
151
- // Artifact containing all APIs and implementations
152
- implementation 'org.jetbrains.kotlinx:dataframe-core:%dataFrameVersion%'
153
- // Optional formats support
154
- implementation 'org.jetbrains.kotlinx:dataframe-json:%dataFrameVersion%'
155
- implementation 'org.jetbrains.kotlinx:dataframe-csv:%dataFrameVersion%'
156
- implementation 'org.jetbrains.kotlinx:dataframe-excel:%dataFrameVersion%'
157
- implementation 'org.jetbrains.kotlinx:dataframe-jdbc:%dataFrameVersion%'
158
- implementation 'org.jetbrains.kotlinx:dataframe-arrow:%dataFrameVersion%'
159
-
160
- // experimental
161
- implementation 'org.jetbrains.kotlinx:dataframe-openapi:%dataFrameVersion%'
162
-
163
- // experimental
164
- // This artifact is only needed to directly call functions that generate @DataSchema code from OpenAPI specifications
165
- // It's used by Gradle and KSP plugins internally.
166
- // Your project needs dataframe-openapi to use generated code
167
- implementation 'org.jetbrains.kotlinx:dataframe-openapi-generator:%dataFrameVersion%'
168
- }
169
- ```
170
-
171
- </tab >
172
-
173
- </tabs >
174
-
175
- <note >
176
- ` dataframe-json ` is included with ` dataframe-csv ` and ` dataframe-excel ` by default. This is to interact with
177
- JSON structures inside CSV and Excel files. If you don't need this functionality, you can exclude it like:
178
- ``` kts
179
- implementation(" org.jetbrains.kotlinx:dataframe-csv:%dataFrameVersion%" ) {
180
- exclude(" org.jetbrains.kotlinx" , " dataframe-json" )
181
- }
182
- ```
183
- </note >
184
-
185
- #### Linter configuration
186
-
187
- We provide a Gradle plugin that generates interfaces with your data.
188
- If you're using any sort of linter, it might complain about them generated sources.
189
-
190
- Use a configuration similar to this to prevent your linter from complaining about the
191
- formatting of the generated sources.
132
+ To enable the plugin in your Gradle project, add it to the ` plugins ` section:
192
133
193
134
<tabs >
194
135
<tab title =" Kotlin DSL " >
195
136
196
137
``` kotlin
197
- // Exclusions for `kotlinter`, if you use it:
198
- tasks.withType< org.jmailen.gradle.kotlinter.tasks.LintTask > {
199
- exclude {
200
- it.name.endsWith(" .Generated.kt" )
201
- }
202
- exclude {
203
- it.name.endsWith(" \$ Extensions.kt" )
204
- }
138
+ plugins {
139
+ kotlin(" plugin.dataframe" ) version " 2.2.20-Beta1"
205
140
}
206
141
```
207
142
@@ -210,25 +145,28 @@ tasks.withType<org.jmailen.gradle.kotlinter.tasks.LintTask> {
210
145
<tab title =" Groovy DSL " >
211
146
212
147
``` groovy
213
- // Exclusions for `kotlinter`, if you use it:
214
- tasks.withType(org.jmailen.gradle.kotlinter.tasks.LintTask).all {
215
- exclude {
216
- it.name.endsWith(".Generated.kt")
217
- }
218
- exclude {
219
- it.name.endsWith("\$Extensions.kt")
220
- }
148
+ plugins {
149
+ id 'org.jetbrains.kotlin.plugin.dataframe' version '2.2.20-Beta1'
221
150
}
222
151
```
223
152
224
153
</tab >
225
- <tab title =" .editorconfig " >
154
+ </tabs >
155
+
156
+ Due to [ this issue] ( https://youtrack.jetbrains.com/issue/KT-66735 ) , incremental compilation must be disabled for now.
157
+ Add the following line to your ` gradle.properties ` file:
226
158
227
- ``` editorconfig
228
- [{**/*.Generated.kt,**/*$Extensions.kt}]
229
- ktlint = disabled
159
+ ``` properties
160
+ kotlin.incremental =false
230
161
```
231
162
232
- </ tab >
163
+ ## Next Steps
233
164
234
- </tabs >
165
+ * Once Kotlin DataFrame is set up in your Android project, continue with the [ ] ( quickstart.md )
166
+ to learn the basics of working with DataFrames.
167
+ * Explore [ detailed guides and real-world examples] ( Guides-And-Examples.md )
168
+ to see how Kotlin DataFrame helps in different data tasks.
169
+ * Check out the
170
+ [ Android project example] ( https://github.com/Kotlin/dataframe/tree/master/examples/android-example )
171
+ and more [ IDEA examples on GitHub] ( https://github.com/Kotlin/dataframe/tree/master/examples/idea-examples ) .
172
+ * Learn more about the [ compiler plugin] ( Compiler-Plugin.md ) .
0 commit comments