https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
l

leandro

10/22/2020, 1:04 PM
Anyone having issues declaring
coreLibraryDesugaring
inside
androidMain
dependencies? It seems that this function does not exist for the
multiplatform
plugin
j

Javier

10/22/2020, 1:40 PM
Are you applying
com.android.library
plugin?
l

leandro

10/23/2020, 10:32 AM
yep
j

Javier

10/23/2020, 10:44 AM
are you using buildSrc?
l

leandro

10/24/2020, 9:59 AM
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

ptsiogas

02/21/2022, 8:33 AM
Hi, I have the same struggle, is there an example to follow? @leandro
l

leandro

02/21/2022, 2:57 PM
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

ptsiogas

02/21/2022, 4:09 PM
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

leandro

02/21/2022, 6:50 PM
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

ptsiogas

02/22/2022, 8:01 AM
I worked fine. Thanks a lot
192 Views