The fix was to migrate from kapt
to ksp
. KSP is the theoretical successor of kapt, and it's developed by Google. To do so, first I had to import the library into my classpath:
buildscript {
...
repositories {
...
classpath "com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin:1.7.0-1.0.6"
...
}
}
Check the latest version from MVN Repository just in case there has been an update, but as the time of writing this the latest version for Kotlin 1.7.0 is 1.7.0-1.0.6
.
Now, in my module's build.gradle
:
plugins {
...
// Remove the old kapt plugin
id 'org.jetbrains.kotlin.kapt'
// Add the new KSP plugin
id 'com.google.devtools.ksp'
...
}
...
android {
...
defaultConfig {
...
// Replace old compile options
javaCompileOptions {
annotationProcessorOptions {
arguments += [ "room.schemaLocation": "$projectDir/schemas".toString() ]
}
}
// With the new KSP arg method
ksp {
arg("room.schemaLocation", "$projectDir/schemas".toString())
}
...
}
...
}
...
dependencies {
...
// Replace all kapt calls with ksp
// kapt "androidx.room:room-compiler:$room_version"
ksp "androidx.room:room-compiler:$room_version"
}
Now Room should be working correctly in Kotlin 1.7.0!