Hi, I'm adding support for the new Android plugin...
# build-tools
k
Hi, I'm adding support for the new Android plugin id("com.android.kotlin.multiplatform.library") in moko-resources, and I've run into a problem caused by androidMain not being treated as an Android target. The generated code does not work with the JVM variant, because the JVM target in KMP has its own resource-handling logic that is incompatible with Android-specific resource access. We correctly detect androidMain, generate sources, and place resources inside androidMain, but Gradle still resolves everything as JVM, which breaks the integration. I haven't found any reliable way to properly support the new Android plugin with its current target model. Here is the link on pr https://github.com/icerockdev/moko-resources/pull/858 Somebody knows additional info about the problem and solution?
@tapchicoma hi, maybe you can help me with this question? thank you
t
I see you are relying on
platformType
. Better to migrate to some other approach, for example to check Kotlin target type. This may fix your problem. fyi @Anton Lakotka [JB]
k
Thanks, Hmm, inside the source set setup there are checks specifically based on the target's plat formType, which we mostly use to determine which of the generators to apply. Right now I removed this from the additional source set configuration and rely only on the target classes, so the platformType enum remains only for internal use (we pass it into the plugin). But this still doesn't answer the question of why androidMain became jvm. Unfortunately, there's very little migration documentation, and I don't yet understand the reasons behind this behavior well enough to provide you with complete information
t
Were you able to solve your problem?
k
No, i no have idea, how setup generated resources/assets/src for new android sourceset in plugin, on current time is blocked updated support of new plugin. I think current config changed sources only for kotlin part of new android plugin, but why i dont know
Additional info: On current time i have question: How enable detection android parts. Why: if i print in console current sourceSets for androidMain, i'm see:
Copy code
๐Ÿค– ANDROID VARIANT: androidMain
   ๐Ÿ“ Android Res (incl. generated): [[/Users/exndy/Documents/Projects/DELETE/moko-resources/samples/gradle-agp-9-sample/shared/src/androidMain/res], [/Users/exndy/Documents/Projects/DELETE/moko-resources/samples/gradle-agp-9-sample/shared/build/generated/moko-resources/androidMain/res], []]
   ๐Ÿ“ Android Assets: [[/Users/exndy/Documents/Projects/DELETE/moko-resources/samples/gradle-agp-9-sample/shared/src/androidMain/assets], [/Users/exndy/Documents/Projects/DELETE/moko-resources/samples/gradle-agp-9-sample/shared/build/generated/moko-resources/androidMain/assets]]
   ๐Ÿ“ Android Kotlin: [/Users/exndy/Documents/Projects/DELETE/moko-resources/samples/gradle-agp-9-sample/shared/build/generated/moko-resources/androidMain/src, /Users/exndy/Documents/Projects/DELETE/moko-resources/samples/gradle-agp-9-sample/shared/src/androidMain/kotlin, /Users/exndy/Documents/Projects/DELETE/moko-resources/samples/gradle-agp-9-sample/shared/build/generated/moko-resources/androidMain/src, /Users/exndy/Documents/Projects/DELETE/moko-resources/samples/gradle-agp-9-sample/shared/src/commonMain/kotlin, /Users/exndy/Documents/Projects/DELETE/moko-resources/samples/gradle-agp-9-sample/shared/build/generated/moko-resources/commonMain/src]
But compilator see only jvm, idea realize correct navigation on resources but res/assets - folders not resources directory. When i try compile code i'm get errors with incorrect implementation expect actual. Any help, why new plugin not activate Android target mode?
a
Hi! The team is on xmas holidays so we cant deep dive. Is your PR enough to reproduce the problem? If not, please provide more detailed description where things start to break but were working with old plugin. And next year ๐ŸงŒ we will comeback with the solution. for now i will take a look at your pr abd mb comment there
k
PR currently matches the described issue. If we found solution, i write about it. Thanks