Anyone having issues declaring `coreLibraryDesugar...
# multiplatform
l
Anyone having issues declaring
coreLibraryDesugaring
inside
androidMain
dependencies? It seems that this function does not exist for the
multiplatform
plugin
j
Are you applying
com.android.library
plugin?
l
yep
j
are you using buildSrc?
l
no… I just created a project on AS 4.1, then created a new MPP module using the Jetbrains plugin, then for the Android dependencies I declared both
compileOptions { coreLibraryDesugaringEnabled true }
and inside dependencies
coreLibraryDesugaring com.android.tools:desugar_jdk_libs:1.0.10
oh, it works if I dont declare it inside androidMain’s dependencies, but as a top level dependencies block
👍 1
🙇‍♂️ 1
p
Hi, I have the same struggle, is there an example to follow? @leandro
l
What have you tried that it didn't work? The solution is to pretty much copy what an android-only module would have
so basically apply the android plugin, create a
dependencies {}
block and add the
coreLibraryDesugaring
inside. You can keep KMM modules depending on kotlinx-datetime
p
When doing all of the above in an Android module it works fine. I would like to apply coreLibraryDesugaring straight to the KMM module in it’s build.gradle.kts file
l
does this work for you?
Copy code
apply plugin: 'com.android.library'
apply plugin: 'org.jetbrains.kotlin.multiplatform'


android {
  compileOptions {
    coreLibraryDesugaringEnabled true
  }
}

kotlin {
  android()
  ios()

  sourceSets {
    commonMain {
      dependencies {
        api libs.kotlin.datetime
      }
    }
    commonTest {
      dependencies {
      }
    }
    iosMain {
      dependencies {
      }
    }
    androidMain {
      dependencies {
      }
    }
  }
}

dependencies {
  coreLibraryDesugaring libs.desugar
}
p
I worked fine. Thanks a lot
647 Views