To enable desugaring in our android-library module we must put this in build.gradle
:
android {
compileOptions {
coreLibraryDesugaringEnabled true
}
}
But we have all scripts migrated to gradle kotlin dsl, so the problem occurs in build.gradle.kts
in all three ways:
android {
compileOptions {
isCoreLibraryDesugaringEnabled = true
}
}
configure<BaseExtension> {
compileOptions {
isCoreLibraryDesugaringEnabled = true
}
}
android {
if (this is com.android.build.api.dsl.LibraryExtension<*, *, *, *, *, *, *, *, *, *, *>) {
buildFeatures.viewBinding = true
}
}
Every time it throws Unresolved reference: isCoreLibraryDesugaringEnabled
.
Does anybody have an idea how to fix this?
When I switch to the newer android plugin version (4.1.0-rc02) it theoretically works. IDE says it's bad syntax, but it works during compilation.
However, it's not an ideal solution
----- FINAL SOLUTION -----
Solution is similar to How to exclude (ignore) android build variants in gradle kts
It wasn't work because of missing line in top-level
build.gradle.kts
this line:classpath("com.android.tools.build:gradle:4.0.1")