Question about the new `com.android.kotlin.multipl...
# multiplatform
d
Question about the new
com.android.kotlin.multiplatform.library
plugin. I've seen many old threads mentioning it doesn't support previews in AS, is that still the case? I'm trying to setup previews in my androidMain code (incrementally migrating existing android code) and have not been able to get it to run. I'm facing the following error:
Copy code
java.lang.ClassNotFoundException: androidx.customview.poolingcontainer.PoolingContainerListener
m
Hi Daniel, thank you for sharing this. I created a ticket https://issuetracker.google.com/issues/422373442 linked to this where you can track the progress. Please feel free to share further details, however, I manage to reproduce it on my end attaching a sample project. In any case, compose preview works using the old plugin so this is quite important to address on our end
thank you color 1
There’s a workaround for it just in case you are interesting and is to add the following dependencies to
commonMain
Copy code
implementation("androidx.compose.ui:ui-tooling:1.8.2")
  implementation("androidx.customview:customview-poolingcontainer:1.1.0")
  implementation("androidx.emoji2:emoji2:1.4.0")
The poolingcontainer is something already documented the other two we need to further understand and try to improve it if possible https://developer.android.com/studio/known-issues#error_when_rendering_compose_preview
d
Cool! I'll try it out soon, but for now I believe I'll continue using the
android.library
plugin (I've just finished configuring sonarqube, jacoco and all of our custom build logic to fully support it) and will migrate once it's fixed. About adding the
androidx.compose.ui:ui-tooling
and
androidx.customview:customview-poolingcontainer
dependencies to the build, wouldn't that increase the final non debug apk with unecessary classes? Or could R8 remove it?
I tried adding those two dependencies but still had some problems with my project. In order for it to work I had to add the following extra deps in addition of the previously mentioned:
Copy code
androidx.activity:activity-compose
androidx.lifecycle:lifecycle-viewmodel-savedstate
androidx.lifecycle:lifecycle-runtime
m
That’s another alternative to keep using
android.library
and then migrate despite not being ideal. The missing dependencies depends completely on your project at least for the shared one I just had to add those. R8 isn’t yet supported so you will have to ensure those dependencies are removed before building the release artifact. However, there’s some ongoing work to make that available as part of
optimization
block
d
When you say R8 isn't supported yet, does this mean that KMP code doesn't get optimized even if imported in an pure android application that runs R8? Or just that on libraries using the androidMultiplatformLibrary R8 will not run?
m
Is not supported in the second scenario
1
thank you color 1