Anybody know what's the problem here? I am using c...
# multiplatform
a
Anybody know what's the problem here? I am using commonMain and androidMain as modules and it keeps complaining. I am on the latest Android Studio version and use Kotlin 2.1.0 with AGP 8.7.2. Also tried with latest versions but no difference.
Full lint message: Function 'HomeContent': expect and corresponding actual are declared in the same module, which will be prohibited in Kotlin 2.0. See https:// youtrack. jetbrains. com/ issue/ KT-55177
h
Which targets do you use?
a
androidTarget() only at the moment
h
That’s the reason of the error message, with 1 target there is only 1 sourceSet, because the common sourceSet is virtual.
a
mhm, so how do i remove the warning?
h
Remove the expect functions and the actual keyword
a
but then id lose the flexibility in the future if everything is in one module right
so basically need to restructure a lot of code and add back expect actual etc.
h
Yeah. Don’t know if you can suppress/ignore the error
b
It looks like you have your expect and actual in the same target. They should be in different targets. Put your actual in the commonMain and your expect in the androidMain. The file must be named properly so you don't get an error. Use the same file name, but the extension should be *.android.kt You should use the expect/actual for as little code as possible. even if its just that one function in the class. Keep everything you can in the common, and just export the one thing you need to the platform.
a
i actually have it that way, i use .android.kt as name convention
Screenshot 2025-02-28 at 16.56.18.png
b
OK, great. so the actual implementation is in the androidMain and the expect is in commonMain?
h
Yeah, but with only 1 target there still will be warnings because the compiler will use commonMain and androidMain.
It does not matter where you put your source code and how you name your files/folders. From compiler view, there is only one source set.
👍 1
b
Yes. Sort of, it does matter where you put your source because different targets have different resolutions. That are not exactly one big source set. More like separate ones that depend on common. At least, that is how my projects work. However, I may misunderstand the problem you are having.