$30 off During Our Annual Pro Sale. View Details »

KMM Kickstart For Android Developers

KMM Kickstart For Android Developers

Overview of the KMM ecosystem for Android developers. We're hiring and training folks, so pushed the basics into a bunch of slides. https://touchlab.co/careers-3/

Kevin Galligan

May 05, 2021
Tweet

More Decks by Kevin Galligan

Other Decks in Technology

Transcript

  1. KMM Kickstart For Android Developers
    Kevin Galligan

    View Slide

  2. Touchlab

    View Slide

  3. View Slide

  4. KMM Kickstart For Android Developers:

    View Slide

  5. KMM Kickstart For Android Developers:
    we’re hiring

    View Slide

  6. Xcode
    Frameworks
    K/N Threading
    Linker?

    View Slide

  7. You fell victim to one of the classic blunders!

    View Slide

  8. We’ll Cover
    • Overview of KMP/KM
    M

    • Status/future of the tec
    h

    • KaMP Ki
    t

    • Architecture Thought
    s

    • Tool
    s

    • Next Steps

    View Slide

  9. Technology Definitions

    View Slide

  10. Kotlin Multiplatform (KMP)

    View Slide

  11. Common
    JVM JS Native

    View Slide

  12. It’s the interop
    generally very good

    View Slide

  13. Common
    JVM JS Native

    View Slide

  14. Common
    JVM JS Native
    iOS Mac
    Linux Windows
    Android/NDK Wasm
    Others…
    Java-6 Java-8
    Android
    Browser
    Node
    Typescript(?)

    View Slide

  15. Kotlin Multiplatform Mobile (KMM)

    View Slide

  16. KMM
    •is mostly a branding designation (it’s still KMP
    )

    •has a dedicated website and docs to help get starte
    d

    •has an Android Studio plugin built just for mobile (ish)

    View Slide

  17. Why KMP/KMM?

    View Slide

  18. kot·lin mul·ti·plat·form


    /ˌkätˈlin məltiˈplatfôrm,ˌkätˈlin məltīˈplatfôrm/


    noun


    noun: kotlin multiplatform


    1.optional, natively-integrated, open-source, code sharing platform, based on the popular,
    modern language kotlin. facilitates non-ui logic availability on many platforms.

    View Slide

  19. kot·lin mul·ti·plat·form


    /ˌkätˈlin məltiˈplatfôrm,ˌkätˈlin məltīˈplatfôrm/


    noun


    noun: kotlin multiplatform


    1.optional, natively-integrated, open-source, code sharing platform, based on the popular,
    modern language kotlin. facilitates non-ui logic availability on many platforms.
    Oh, and JetBrains!

    View Slide

  20. Shared Native Code
    not “cross platform”

    View Slide

  21. Android is Kotlin
    half of it isn’t “cross platform”

    View Slide

  22. Not (necessarily) UI
    Compose and Swift UI compatible!

    View Slide

  23. View Slide

  24. View Slide

  25. Low Risk
    bigger orgs worry about such

    View Slide

  26. Memory Lane

    View Slide

  27. 2020 is KMP’s year
    it’s all coming together

    View Slide

  28. View Slide

  29. https://kotlinlang.org/lp/mobile/case-studies/

    View Slide

  30. View Slide

  31. KMM Developer
    https://touchlab.co/careers-3/

    View Slide

  32. KMM Developer
    https://touchlab.co/careers-3/
    (Remote, now and post-pandemic)

    View Slide

  33. KMM Status
    it’s complicated

    View Slide

  34. https://kotlinlang.org/docs/mobile/kmm-evolution.html
    Kotlin/JVM Stable
    Kotlin/Native Runtime Beta
    Multiplatform Gradle plugin Beta
    Kotlin/Native interop with C and Objective C Beta
    CocoaPods integration Beta
    Multiplatform IDE support Alpha
    KMM plugin for Android Studio Experimental

    View Slide

  35. View Slide

  36. https://www.youtube.com/watch?v=L8Xq15NTuCc

    View Slide

  37. KaMP Kit

    View Slide

  38. View Slide

  39. May 2021
    where are we?

    View Slide

  40. https://kotlinlang.org/lp/mobile/

    View Slide

  41. View Slide

  42. First 5 Minutes
    hit the ground running

    View Slide

  43. View Slide

  44. View Slide

  45. Alternatives we like…

    View Slide

  46. https://github.com/joreilly/PeopleInSpace

    View Slide

  47. https://github.com/joreilly/PeopleInSpace

    View Slide

  48. https://github.com/Kotlin/kmm-production-sample

    View Slide

  49. But Compose?!
    one new thing at a time

    View Slide

  50. OK, Actually Starting
    they say never live code…

    View Slide

  51. OK, Actually Starting
    they say never live code…

    View Slide

  52. General Patterns
    what we’re seeing

    View Slide

  53. Specific Modules

    View Slide

  54. Analytics
    Android Framework
    Android


    Stuff
    iOS


    Stuff

    View Slide

  55. Shared Architecture

    View Slide

  56. Analytics
    Android Framework
    Android


    Stuff
    iOS


    Stuff

    View Slide

  57. App Stuff
    Android Framework
    Android


    Stuff
    iOS


    Stuff

    View Slide

  58. KaMP Kit is Shared Architecture

    View Slide

  59. View Slide

  60. I’m mostly not UI layer

    View Slide

  61. LinearLayout FTW
    Compost?
    fill_parent?

    View Slide

  62. App Stuff
    Android Framework
    Android


    Stuff
    iOS


    Stuff

    View Slide

  63. App Stuff
    Framework

    View Slide

  64. App Stuff
    Framework
    lambda lambda

    View Slide

  65. App Stuff
    Framework
    VM/Lifecycle


    Coroutines

    View Slide

  66. Android is pretty simple
    iOS is a debate

    View Slide

  67. App Stuff
    Framework
    lambda
    VM/Lifecycle


    Coroutines

    View Slide

  68. Compiler Created Interfaces
    call suspend functions from iOS

    View Slide

  69. Community Libraries

    View Slide

  70. Working on a thing
    coming soon…

    View Slide

  71. App Stuff
    Framework
    VM/Lifecycle


    Coroutines
    VC/Lifecycle-


    Aware
    Coroutine Scope/


    Interface Manager

    View Slide

  72. App Stuff
    Framework
    lambda
    VM/Lifecycle


    Coroutines

    View Slide

  73. Libraries

    View Slide

  74. Libraries
    • SQLDelight (DB
    )

    • Ktor (Networking
    )

    • Kotlinx.Serialization (Json
    )

    • Kotlinx.Coroutines (Async/
    Concurrency)
    • Kermit (logging
    )

    • Multiplatform Settings (Key/Value
    )

    • Stately (K/N Concurrency
    )

    • Koin (DI/not-DI?)

    View Slide

  75. View Slide

  76. CREATE TABLE Breed (


    id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,


    name TEXT NOT NULL UNIQUE,


    favorite INTEGER NOT NULL DEFAULT 0


    );


    selectAll:


    SELECT * FROM Breed;


    selectById:


    SELECT * FROM Breed WHERE id = ?;


    selectByName:


    SELECT * FROM Breed WHERE name = ?;


    insertBreed:


    INSERT OR IGNORE INTO Breed(id, name)


    VALUES (?,?);


    deleteAll:


    DELETE FROM Breed;


    updateFavorite:


    UPDATE Breed SET favorite = ? WHERE id = ?;


    View Slide

  77. public data class Breed(


    public val id: Long,


    public val name: String,


    public val favorite: Long


    ) {


    public override fun toString(): String = """


    |Breed [


    | id: $id


    | name: $name


    | favorite: $favorite


    |]


    """.trimMargin()


    }

    View Slide

  78. public interface TableQueries : Transacter {


    public fun selectAll(mapper: (


    id: Long,


    name: String,


    favorite: Long


    ) -> T): Query


    public fun selectAll(): Query


    public fun selectById(id: Long, mapper: (


    id: Long,


    name: String,


    favorite: Long


    ) -> T): Query


    public fun selectById(id: Long): Query


    public fun selectByName(name: String, mapper: (


    id: Long,


    name: String,


    favorite: Long


    ) -> T): Query


    //Yada yada


    }

    View Slide

  79. Tools

    View Slide

  80. Android Studio
    obviously

    View Slide

  81. View Slide

  82. Xcode
    you’re *definitely* going to use Xcode

    View Slide

  83. https://github.com/touchlab/xcode-kotlin

    View Slide

  84. Some More Info

    View Slide

  85. Kotlin/Native Concurrency

    View Slide

  86. Common
    JVM JS Native

    View Slide

  87. View Slide

  88. Two Rules
    it’s actually pretty simple

    View Slide

  89. Mutable == 1 thread

    View Slide

  90. Immutable == many threads

    View Slide

  91. Immutable means Frozen
    call freeze()

    View Slide

  92. View Slide

  93. Xcode Frameworks
    like AAR’s (kind of)

    View Slide

  94. Xcode Frameworks
    like AAR’s (kind of)

    View Slide

  95. Xcode Frameworks
    like AAR’s (kind of)

    View Slide

  96. Interface is Objective-C
    swift is pretty good at talking to Objc

    View Slide

  97. Analytics
    Android Framework
    Android


    Stuff
    iOS


    Stuff

    View Slide

  98. Analytics
    Android Framework
    Android


    Stuff
    iOS


    Stuff
    Tax Calc
    Framework

    View Slide

  99. Analytics
    Android Framework
    Android


    Stuff
    iOS


    Stuff
    Tax Calc
    Framework

    View Slide

  100. https://www.youtube.com/watch?v=hrRqX7NYg3Q

    View Slide

  101. Touchlab

    View Slide

  102. What’s Next?

    View Slide

  103. KaMP Kit Docs
    • More on Concurrenc
    y

    • “Selling” to your tea
    m

    • Some info on integrating with existing project
    s

    • Other assorted docs

    View Slide

  104. Kotlin Slack
    this is critical

    View Slide

  105. https://kotlinlang.org/lp/mobile/

    View Slide

  106. Final Words
    quick Touchlab pitch

    View Slide

  107. View Slide

  108. KMM Developer
    https://touchlab.co/careers-3/

    View Slide

  109. KMM Developer
    https://touchlab.co/careers-3/
    Will train Android devs!

    View Slide

  110. KMM Developer
    https://touchlab.co/careers-3/
    (Also looking for KMP/KMM experts)

    View Slide

  111. View Slide

  112. View Slide

  113. Thanks!
    @kpgalligan
    touchlab.co

    View Slide