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

Kris Wong

07/22/2019, 4:21 PM
does anyone have an example of an MPP (not an app project) w/ an android library target?
interesting the first one created a main source set just to place AndroidManifest.xml
thanks! the second seems a little cleaner.
r

russhwolf

07/22/2019, 4:39 PM
The Android plugin doesn't know how to read the manifest out of the multiplatform plugin's sourcesets, so you need to put the manifest in
main
instead of
androidMain
k

kpgalligan

07/22/2019, 4:39 PM
In the second one you need to map the kotlin source sets to where android expects them. See “4. Android Specific Configuration”. Both cases have some not-ideal config, but not horrible. I followed the multiplatform settings model yesterday and it worked quite well
Don’t forget
Copy code
android {
        publishAllLibraryVariants()
    }
k

Kris Wong

07/22/2019, 4:41 PM
yes, the second one is clear on that
the source sets that is
i am not seeing any discussion on publishAllLibraryVariants
r

russhwolf

07/22/2019, 4:45 PM
It ensures that you publish both release and debug configurations
k

Kris Wong

07/22/2019, 4:46 PM
publish to where
r

russhwolf

07/22/2019, 4:46 PM
as a maven dependency
ie as something that you'd import in your dependencies block
k

Kris Wong

07/22/2019, 4:47 PM
yeah i won't be publishing
at least not at first. perhaps to artifactory going forward.
r

russhwolf

07/22/2019, 4:48 PM
Probably not a big deal yet then
k

Kris Wong

07/22/2019, 4:49 PM
gotcha. thanks.
seems to be working, but none of the IDE features work in the Android sources
no code completion, no auto-imports, no error highlighting
it doesn't even seem to understand that it is source code at all
yep - doesn't recognize it as a sources root
s

Sergioedcigreja

07/22/2019, 7:44 PM
But if you expect a class in common does it ask you to create the actual class in the android side?
k

Kris Wong

07/22/2019, 7:44 PM
the compiler does
the IDE only informs me to create one in iosMain
s

Sergioedcigreja

07/22/2019, 7:45 PM
hum
k

Kris Wong

07/22/2019, 7:45 PM
this may have happened because I started this project from a template that used jvm, and I switched it
s

Sergioedcigreja

07/22/2019, 7:46 PM
I think the easiest is to create a new project with the default that gives you both an android and ios app
in intellij idea.. cant remember the exact name
k

Kris Wong

07/22/2019, 7:47 PM
I don't need apps. apps I have 🙂
s

Sergioedcigreja

07/22/2019, 7:47 PM
then you delete the ios app and in build.gradle of the library
you change from application to library
yeah I know what you want to do
i'm doing something similar
k

Kris Wong

07/22/2019, 7:51 PM
i mean that's essentially the same thing I have done through a different path
interesting that that template doesn't create
androidMain
and
androidTest
, though it does specify dependencies for those source sets via the kotlin block in build.gradle
s

Sergioedcigreja

07/22/2019, 7:52 PM
in my project I dont use those either
k

Kris Wong

07/22/2019, 7:53 PM
seems like this particular setup still needs some more thought from the Kotlin team
the android dependencies
I put them outside of kotlin
k

Kris Wong

07/22/2019, 7:56 PM
alright, thanks for the workaround
hah, making a change to build.gradle and rerunning the import fixed it
👍 1
2 Views