Hi! I’m having strange problem with an `actual` cl...
# multiplatform
a
Hi! I’m having strange problem with an
actual
class. I do follow the example in KaMPKit. Although everything works fine in KaMPKit standalone project, in my project which is a separate project and implements shared lib can not resolve
actual
class imports in
androidMain
but resolves
iosMain
😄 Any thoughts about what the reason might be? Thanks in advance.
m
I don't know if by
androidMain
you mean the Kotlin source set called
androidMain
or a directory called
androidMain
. If you mean the directory, then the problem maybe caused by the default behavior for android target. Android in KMM defaults to using the directories
main
and
test
for where to look for their source files. Many people add
androidMain
directory to the
androidMain
source set to make Android follow patterns of the other platforms.
I don't see anything like that in the gradle files for KaMPKit so the info I posted about maybe out of date.
I would double check that your IDE is showing the
androidMain/Kotlin
directory as a source root.
a
They have used extension lately.
androidMain
below points to the source set
Copy code
sourceSets {
val androidMain by getting {
To clarify; I reach
shared
source code through my app project and nothing seems to be resolved in
androidMain
directory in shared lib. By the way, see the screenshot. It looks like that in the shared lib project. So,
main
might be a problem here I guess.
k
@Alper Tekin I'm experiencing this as well 😅
😅 1
a
@Kwabena Berko good news! 🦜 Add the code block below to your shared build.gradle.kts file
Copy code
android {   
 sourceSets {
        getByName("main") {        java.srcDir("src/androidMain/kotlin")
        }
    }
}
🙏 1