Hi, I'm trying to migrate my KMP module from `com....
# multiplatform
v
Hi, I'm trying to migrate my KMP module from
com.android.library
to the newer
com.android.kotlin.multiplatform.library
, but I'm hitting the restriction of limited support for build variants and custom compilations. I've checked migration steps, but I don't see any possible solution for my project. I use source sets
androidDebug
and
androidRelease
for different Android resources (namely
shortcuts.xml
), also I use branching logic based on generated build config's
isDebug
property (provided by the plugin
com.github.gmazzo.buildconfig
), which is also wired using source sets. The module in question is here, if anyone is keen to take a look or hack, please be my guest.
e
For logic, it looks like they suggest https://github.com/yshrsmz/BuildKonfig, but that doesn't help with wanting to exclude code from the final binary (although I supposed R8 should be able to prune it). Not sure how to handle resources though. I guess it's the same idea, where you have the resources in the same module, and the one that you don't reference in the final binary gets pruned by R8, but I'm not sure.
w
You still get build variant support in the final application module, so you could split your module up into libdebug and librelease and then choose the right one in the app module. This does make it a lot harder since you have to share the common interface/accessors manually. Maybe you can do some trickery with compileOnly and runtimeOnly, but otherwise you'd need to abstract the way the resources are read so that you can recreate expect/actual.
For isDebug I've just been maintaining a dedicated module which still uses
com.android.library
which I expect/actual and is only imported into the
androidMain
source set. But I'm thinking of moving to the build variant separate modules approach to unify on a single module setup.
c
Yeah, I understand the change they made, but they need way better migration steps, we've held off because of this, so much debug/release logic in our main shared-app module
1
👍🏻 1