https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
b

Big Chungus

04/20/2021, 7:44 AM
Is it possible to build stuff for androidTV and wearOS with kotlin multiplatform?
🙂 1
j

Javier

04/20/2021, 7:45 AM
wearOS for sure, there are targets. For AndroidTV I have no idea, but probably yes
b

Big Chungus

04/20/2021, 7:46 AM
There's wearOS target?? Thought there's only watchOS
j

Javier

04/20/2021, 7:48 AM
Sorry, I read watchOS
My bad, then I am not sure, probably you have to create múltiple android targets
Is it not the same that an Android app? I mean, you just create the standalone app with no kmp
or you are trying to share a wearOS lib?
b

Big Chungus

04/20/2021, 7:51 AM
Just experimenting, really. Think of it as a lib
I think they are just normal app/library modules, so you can just create a normal android target
t

Thomas

04/20/2021, 8:38 AM
Works fine, I am using multiplatform modules for both Wear OS and Android TV. They are just Android devices which need a different UI.
b

Big Chungus

04/20/2021, 8:40 AM
How do you declare them in kotlin targets block? Or can you just repeat android() target?
t

Thomas

04/20/2021, 8:40 AM
You can just use the same android() target as you probably would like to share the same code
b

Big Chungus

04/20/2021, 8:41 AM
How do you implement two different UIs in the same target, then?
t

Thomas

04/20/2021, 8:41 AM
Then create multiple standard Android modules, one for mobile, one for wear os, one for TV, which all depend on the multiplatform one.
b

Big Chungus

04/20/2021, 8:41 AM
Ah, got it
t

Thomas

04/20/2021, 8:41 AM
Put the UI code in there
b

Big Chungus

04/20/2021, 8:41 AM
Was expecting something more uniform
I hate that android is a "special snowflake" and breaks usual MPP layout...
2
t

Thomas

04/20/2021, 8:43 AM
Well this is how I am doing it which is working great. I tried sharing UI but that is just not really useful as the devices are so different. You could share some custom views and resources by putting them in the shared module, but that's it.
Maybe you could use Android flavors in the shared module, one for mobile, wear, and tv. But I am not sure how good that will work.
31 Views