Can someone help me get some clarity on the differ...
# multiplatform
d
Can someone help me get some clarity on the difference between these 2 plugins?
Copy code
'com.android.kotlin.multiplatform.library' and 'com.android.library' plugins cannot be applied in the same project.
Which one should I use? what are the drawbacks of using one or the other? If I apply the
com.android.library
I need to add
androidTarget()
to the
kotlin
configuration with multiplatform and I keep using the standard
android
configuration. However if I add the
com.android.kotlin.multiplatform.library
I need to use
androidLibrary { }
instead. Android Studio generate multiplatform libraries with
com.android.kotlin.multiplatform.library
. If I recall I went with
com.android.library
because with the other Android Studio wasn’t showing compose previews. I’d really appreciate if someone could shed some light on this. I couldn’t find any documentation on this. Thank you
s
I can't tell you what to use, but I can tell you for my library, I'm using this:
Copy code
plugins {
    id("com.android.library")
    kotlin("multiplatform")
}
This allows me to create a KMP library with an android target
My assumption is that you're trying to create a KMP library, in which case you can take a look at my buildSrc script that I use to build library components: https://github.com/schott12521/compose-cupertino/blob/main/buildSrc/src/main/kotlin/multiplatform-module-convention.gradle.kts
t
com.android.kotlin.multiplatform.library
is a new plugin from Google for KMP/Android target. Eventually "com.android.library" will stop working in KMP, but it will be not soon
The difference between them that in the "com.android.library" case KMP calls AGP public APIs to fit it in KMP project model. In the other case new plugin will call KMP special API to configure Android target in KMP project model
d
Thank you @tapchicoma . What I take away is that
com.android.kotlin.multiplatform
is the future. Right now they are more or less equivalent. Right now this plugin doesn't work with previews in android studio, I should check it periodically to do the switch
t
I think you should wait for official announcement that should be around Kotlin 2.2.0
d
Sound reasonable thank you!