Hello guys, I have a question, I created project w...
# multiplatform
m
Hello guys, I have a question, I created project with standart Android Studio KMM plugin. And then I added also my
backend
module into project as
jvm
target but surprisingly backend Module is not seeing
commonJvm
rather it sees
commonAndroid
expected values. Also I can not reach the class in
commonMain
from
backend
module. Did anyone had similar issue ? You can see the gradle.kts files in thread
backend build.gradle.kts
common build.gradle.kts
a
You can't have Android and JVM applications in the same project yet. I think there's an open issue for that.
m
Ohh really 🤔 but I have seen some repos with both JVM and Android. Like https://github.com/jarroyoesp/KotlinMultiPlatform https://github.com/joreilly/PeopleInSpace
a
There are, but I don't think they work TBH, but I could be wrong.
m
PeopleInSpace, works on my local
a
Are you sure? Cuz as I remember on one of my projects, i tried it and it didn't work, I came across this tho https://stackoverflow.com/questions/59479020/how-to-share-java-code-between-android-and-jvm-targets-with-kotlin-multiplatfor but didn't work either.
m
Yes, but it is weird, i add some classes in PeopleInSpace it behaved like how it is for me On the other
PeopleInSpaceApi
(located in
commonMain
) https://github.com/joreilly/PeopleInSpace/blob/master/common/src/commonMain/kotlin/com/surrus/common/remote/PeopleInSpaceApi.kt can be reachable from
backend
module should be some trick to achieve this, I created a new class in same file couldn’t reach it
s
Hi guys, i have exactly the same issue. I don't understand why in PeopleInSpace project is working... hmm 🤔
m
@John O'Reilly maybe you can explain us since you are the repository owner 🙂
j
If you can fork PeopleInSpace and repo issue you're seeing I'll try and get some time later to take a look
m
Hey, No we do not see any issue your repo works fine 🙂 and we wonder how you managed to access
commonMain
classes in
backend
module. Is there any trick for that ? It seems we are having issues and
backend
module only sees
androidMain
for some reason.
j
"i add some classes in PeopleInSpace it behaved like how it is for me" was referring to this....sounded like you were able to reproduce same issue using PeopleInSpace (by adding some class?)...but I might have misunderstood?
I guess main thing is that following is in
backend
module gradle file but presume you probably something like that in your project as well?
Copy code
implementation(project(":common"))
m
yeap i have
Copy code
implementation(project(":common"))
but something is still missing, On the other hand I download your repo, you have
PeopleInSpaceApi
class in
commonMain
and you can use it in
Server.kt
, tested working, I created
TestCommon
class in same file couldn’t access it in
Server.kt
So I started to wonder if there is any extra step to make
commonMain
files visible in
backend
module
j
I don't believe I did anything else specifically to allow that (though perhaps did so inadvertently 🙂 )
s
Thanks John. Which version of AS are you using? I tried stable, alpha, beta and I have the same issue in my personal project like @Mustafa Ozhan Still wondering why it only works in your project only 🙂
j
I'm using 4.2 Canary 13 at the moment (have to use that for Jetpack Compose right now)
m
To clarify the weird problem please check the video 🙂 I hope I demonstrated it good 🙂
Meanwhile, I downloaded
4.2 Canary 13
and tested results are same
j
so, I tried to replicate that here....like you it didn't show
TestCommonMain
as option as I was typing it.....but....was able to add as import and could resolve it then
Copy code
import com.surrus.common.TestCommonMain
so perhaps some issue with AS
m
Interesting 😕 manually not working for me either, will try to clean Android Studio compeletelly and use latest version
s
@Mustafa Ozhan Finally I got it. Clean everything. Remove .gradle, .idea, build folders for every single module. After that, invalidate caches and restart. Now I can have access to 'commonMain' 🙂
I just did this using 4.2 Canary 13
m
Okay finally I make it work too 🙂 thanks a lot guys 🙂