Slide 1

Slide 1 text

KMM Kickstart For Android Developers Kevin Galligan

Slide 2

Slide 2 text

Touchlab

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

KMM Kickstart For Android Developers:

Slide 5

Slide 5 text

KMM Kickstart For Android Developers: we’re hiring

Slide 6

Slide 6 text

Xcode Frameworks K/N Threading Linker?

Slide 7

Slide 7 text

You fell victim to one of the classic blunders!

Slide 8

Slide 8 text

We’ll Cover • Overview of KMP/KM M • Status/future of the tec h • KaMP Ki t • Architecture Thought s • Tool s • Next Steps

Slide 9

Slide 9 text

Technology Definitions

Slide 10

Slide 10 text

Kotlin Multiplatform (KMP)

Slide 11

Slide 11 text

Common JVM JS Native

Slide 12

Slide 12 text

It’s the interop generally very good

Slide 13

Slide 13 text

Common JVM JS Native

Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

Kotlin Multiplatform Mobile (KMM)

Slide 16

Slide 16 text

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)

Slide 17

Slide 17 text

Why KMP/KMM?

Slide 18

Slide 18 text

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.

Slide 19

Slide 19 text

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!

Slide 20

Slide 20 text

Shared Native Code not “cross platform”

Slide 21

Slide 21 text

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

Slide 22

Slide 22 text

Not (necessarily) UI Compose and Swift UI compatible!

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

Low Risk bigger orgs worry about such

Slide 26

Slide 26 text

Memory Lane

Slide 27

Slide 27 text

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

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

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

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

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

Slide 32

Slide 32 text

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

Slide 33

Slide 33 text

KMM Status it’s complicated

Slide 34

Slide 34 text

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

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

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

Slide 37

Slide 37 text

KaMP Kit

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

May 2021 where are we?

Slide 40

Slide 40 text

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

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

First 5 Minutes hit the ground running

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

Alternatives we like…

Slide 46

Slide 46 text

https://github.com/joreilly/PeopleInSpace

Slide 47

Slide 47 text

https://github.com/joreilly/PeopleInSpace

Slide 48

Slide 48 text

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

Slide 49

Slide 49 text

But Compose?! one new thing at a time

Slide 50

Slide 50 text

OK, Actually Starting they say never live code…

Slide 51

Slide 51 text

OK, Actually Starting they say never live code…

Slide 52

Slide 52 text

General Patterns what we’re seeing

Slide 53

Slide 53 text

Specific Modules

Slide 54

Slide 54 text

Analytics Android Framework Android Stuff iOS Stuff

Slide 55

Slide 55 text

Shared Architecture

Slide 56

Slide 56 text

Analytics Android Framework Android Stuff iOS Stuff

Slide 57

Slide 57 text

App Stuff Android Framework Android Stuff iOS Stuff

Slide 58

Slide 58 text

KaMP Kit is Shared Architecture

Slide 59

Slide 59 text

No content

Slide 60

Slide 60 text

I’m mostly not UI layer

Slide 61

Slide 61 text

LinearLayout FTW Compost? fill_parent?

Slide 62

Slide 62 text

App Stuff Android Framework Android Stuff iOS Stuff

Slide 63

Slide 63 text

App Stuff Framework

Slide 64

Slide 64 text

App Stuff Framework lambda lambda

Slide 65

Slide 65 text

App Stuff Framework VM/Lifecycle Coroutines

Slide 66

Slide 66 text

Android is pretty simple iOS is a debate

Slide 67

Slide 67 text

App Stuff Framework lambda VM/Lifecycle Coroutines

Slide 68

Slide 68 text

Compiler Created Interfaces call suspend functions from iOS

Slide 69

Slide 69 text

Community Libraries

Slide 70

Slide 70 text

Working on a thing coming soon…

Slide 71

Slide 71 text

App Stuff Framework VM/Lifecycle Coroutines VC/Lifecycle- Aware Coroutine Scope/ Interface Manager

Slide 72

Slide 72 text

App Stuff Framework lambda VM/Lifecycle Coroutines

Slide 73

Slide 73 text

Libraries

Slide 74

Slide 74 text

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?)

Slide 75

Slide 75 text

No content

Slide 76

Slide 76 text

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 = ?;

Slide 77

Slide 77 text

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() }

Slide 78

Slide 78 text

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 }

Slide 79

Slide 79 text

Tools

Slide 80

Slide 80 text

Android Studio obviously

Slide 81

Slide 81 text

No content

Slide 82

Slide 82 text

Xcode you’re *definitely* going to use Xcode

Slide 83

Slide 83 text

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

Slide 84

Slide 84 text

Some More Info

Slide 85

Slide 85 text

Kotlin/Native Concurrency

Slide 86

Slide 86 text

Common JVM JS Native

Slide 87

Slide 87 text

No content

Slide 88

Slide 88 text

Two Rules it’s actually pretty simple

Slide 89

Slide 89 text

Mutable == 1 thread

Slide 90

Slide 90 text

Immutable == many threads

Slide 91

Slide 91 text

Immutable means Frozen call freeze()

Slide 92

Slide 92 text

No content

Slide 93

Slide 93 text

Xcode Frameworks like AAR’s (kind of)

Slide 94

Slide 94 text

Xcode Frameworks like AAR’s (kind of)

Slide 95

Slide 95 text

Xcode Frameworks like AAR’s (kind of)

Slide 96

Slide 96 text

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

Slide 97

Slide 97 text

Analytics Android Framework Android Stuff iOS Stuff

Slide 98

Slide 98 text

Analytics Android Framework Android Stuff iOS Stuff Tax Calc Framework

Slide 99

Slide 99 text

Analytics Android Framework Android Stuff iOS Stuff Tax Calc Framework

Slide 100

Slide 100 text

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

Slide 101

Slide 101 text

Touchlab

Slide 102

Slide 102 text

What’s Next?

Slide 103

Slide 103 text

KaMP Kit Docs • More on Concurrenc y • “Selling” to your tea m • Some info on integrating with existing project s • Other assorted docs

Slide 104

Slide 104 text

Kotlin Slack this is critical

Slide 105

Slide 105 text

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

Slide 106

Slide 106 text

Final Words quick Touchlab pitch

Slide 107

Slide 107 text

No content

Slide 108

Slide 108 text

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

Slide 109

Slide 109 text

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

Slide 110

Slide 110 text

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

Slide 111

Slide 111 text

No content

Slide 112

Slide 112 text

No content

Slide 113

Slide 113 text

Thanks! @kpgalligan touchlab.co