This documentation page <https://kotlinlang.org/do...
# multiplatform
d
This documentation page https://kotlinlang.org/docs/multiplatform-android-dependencies.html on kotlin multiplatform android depencencies states: > to move a
debugImplementation
dependency from the top level of an Android project, you’ll need to add an implementation dependency to the source set named
androidDebug
. To minimize the effort you have to put in to deal with migration problems like this, you can add a
dependencies {}
block inside the
androidTarget {}
block: however when I try to use
androidTarget {}
in either the build.gradle.kts sourceSets block or inside a build-convention plugin I get this error:
Copy code
The target 'android' already exists, but it was not created with the 'android' preset. To configure it, access it by name in `kotlin.targets`.
I’ve already tried applying the
com.android.kotlin.multiplatform.library
before the
org.jetbrains.kotlin.multiplatform
plugin without any change in the error message And if I try using
Copy code
getByName("androidDebug") { }
I get
Copy code
KotlinSourceSet with name 'androidDebug' not found.
So, apparently this issue I had was caused by me using
com.android.kotlin.multiplatform.library
plugin over
com.android.library
. they are both plugins released by Google with AGP, the first is newer and is supposedly going to eventually replace
com.android.library
for multiplatform libraries using Android (but I actually hope they’ll take another route, cause multiplatform and android library shouldn’t be put together IMHO). The 2 plugin conflict with each other, if you use
com.android.library
you cannot also use
com.android.kotlin.multiplatform.library
. If you use the regular
com.android.library
than it does what is needed to init the android component and therefore you can than use
androidTarget { }
inside the
kotlin { }
section of configuration for the
org.jetbrains.kotlin.multiplatform
plugin. AND if you use
com.android.library
android studio will support compose previews in
androidMain
while if you use
com.android.kotlin.multiplatform.library
the preview will not be available. Conclusion of all this: do not use
com.android.kotlin.multiplatform.library
, at least not yet.
I’ll add I found no way to target
debutImplementation
with dependencies using
com.android.kotlin.multiplatform.library
(which might not mean there isn’t one, I just couldn’t find one)
g
Hi, Daniele! I move out from this plugin too. how did you setup the android tests with the old plugin?