Slide 1

Slide 1 text

Compose interoperability challenges Julien Salvi - Android GDE | Android @ Aircall DevFest Stockholm 2025 󰐴 @jusalvi.bsky.social and how to face them! 🤓

Slide 2

Slide 2 text

Julien Salvi Android @ Aircall Android GDE PAUG, Punk & IPAs! @jusalvi.bsky.social Bonjour !

Slide 3

Slide 3 text

Migrating to Compose A little bit of context… A little bit of context… Which strategy to adopt? 🧐

Slide 4

Slide 4 text

Happy is a happy developer! But to be happier, they want to use Compose in their applications

Slide 5

Slide 5 text

Yeah! Let’s go full Compose! But which strategy to adopt?

Slide 6

Slide 6 text

Migrating to Compose Which strategy? ● Developers or teams can face 3 different scenarios when migrating to Compose: From scratch Migrating all at once because the app is small enough Introduce Compose step by step for big apps

Slide 7

Slide 7 text

Happy has a huge codebase! Let’s see how to gradually introduce Compose in a project 💻

Slide 8

Slide 8 text

Migrating to Compose Migration Plan ● Key pillars of the migration plan you should keep in mind: ○ Architecture ○ Navigation ○ Interoperability ○ Testability ● Let’s explore some tips to best achieve the Compose migration

Slide 9

Slide 9 text

Interoperability tips A little bit of context… A little bit of context… To avoid (bad) surprises when migrating 🙈

Slide 10

Slide 10 text

Architecture assessment ⚙ The foundation should be strong

Slide 11

Slide 11 text

Architecture assessment ⚙ Is your app Compose ready? ● Before migrating your entire app to Compose make sure the architecture you are using fits the Compose paradigms ● Avoid architectures that depend on mutable shared state or bidirectional data binding when working with Compose ● Let’s take the example of our architecture move 💡

Slide 12

Slide 12 text

Architecture assessment ⚙

Slide 13

Slide 13 text

Architecture assessment ⚙

Slide 14

Slide 14 text

Architecture assessment ⚙ LiveData vs StateFlow ● LiveData can be used with Compose without any issue but are very platform specific ● To have a more agnostic approach consider using StateFlow (Kotlin lib) that can be safely collected in Compose screens. ● LiveData and StateFlow can coexist well together for transition purposes but favor a full usage of StateFlow 💡

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

Theming interoperability 🎨 Quest for consistency!

Slide 18

Slide 18 text

Theming 🎨 Colors and dimens ● Composable and View components will have two distinct theming implementations (code vs xml) ● If the app strictly relies on Material theme, the interop between the themes can be straightforward matching the colors ● If using a custom theme no magic tricks to ease the migration unfortunately 🥲

Slide 19

Slide 19 text

Theming 🎨 Material Components ● Not all Material View Components have been migrated to Compose yet ● And some Composable are missing features that were existing in the View system components ● Let’s take the example of the DatePicker 💡

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

Navigating with Compose 🧭 Always in motion the future is!

Slide 23

Slide 23 text

Navigating with Compose 🧭 Check current nav ● Assess your current navigation system inside your app (the complexity of the graph, which components…) ● If you are using androidx navigation with Fragment, keep the Fragment as holder till end of the migration and then remove all the Fragments to be full Compose (easiest transition) ● Custom navigation == Custom problems 😅

Slide 24

Slide 24 text

Navigating with Compose 🧭 Compose Nav ● We decided to go with Voyager for our Compose Navigation system as it has many benefits: ○ Great API that fits our needs ○ Easy multi module navigation with ScreenRegistry ○ Type safe navigation

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

Navigating with Compose 🧭 Feature isolation ● Currently, a global router manages the navigation between Activity, Fragments, modals and external links ● The router has its own stack and is very tight to the View framework ● So how to introduce our new Compose navigation that can coexist with the current one? 💡

Slide 27

Slide 27 text

Navigating with Compose 🧭 Feature isolation ● We decided to fragment the app per Universe where each “Universe” is an Activity that is used in the application ● Once all Fragments and BottomSheets have been migrated, you can now get rid of the fragments in each “Universe” and use the new Compose nav safely. ● The old router will only be there to open new Activity but inside it full Compose

Slide 28

Slide 28 text

Communication Compose <> View 📡 Sending…

Slide 29

Slide 29 text

Communication 📡 Compose to View ● During the migration you might want to send events to your View components (Acitivity, Fragments…) ● Example: the feedback alert system was not migrated yet but needed to be trigger from Compose code ● Let’s see how to do it thanks to CompositionLocal 💡

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

Testing interoperability 🧪 Testing is NOT doubting!

Slide 33

Slide 33 text

Testing ● Make sure you keep your screen testable ● Compose has a great API to add test tags to your Composable ● Try to keep the same tag ID from View to Compose to ease the migration ● If a QA team is in charge of the UI tests, sync early and make a POC UI tests

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

Testing https://medium.com/@juliensalvi/ui-test s-with-jetpack-compose-and-appium-x -uiautomator-5d276fb655aa UI tests

Slide 37

Slide 37 text

Testing ● Layout inspector is great to check the Compose tree or the recomposition counts in your apps ● Works perfectly with a mix of View and Compose ● Here are 2 tips to keep in mind 💡 Layout inspector

Slide 38

Slide 38 text

Testing ● 💡Not seeing Composable in layout inspector? ○ Make sure you are not removing META-INF/androidx.compose.*.version file from the APK ● 💡Application is crashing with layout inspector? ○ Don’t use semantics(mergeDescendants = true) in your base Composable component (e.g. Scaffold) Layout inspector

Slide 39

Slide 39 text

Compose learning in a team 🤓 Sharing is caring!

Slide 40

Slide 40 text

Compose interoperability Migrate to Compose https://developer.android.com/develop/ui/compose/migrate Interoperability APIs https://developer.android.com/develop/ui/compose/migrate/interoperability-apis Coupling Compose - interoperability in a legacy codebase https://www.droidcon.com/2023/10/06/coupling-compose-interoperability-in-a-legacy-codebase/ Migrating to Jetpack Compose - an interop love story https://medium.com/androiddevelopers/migrating-to-jetpack-compose-an-interop-love-story-part- 1-3693ca3ae981

Slide 41

Slide 41 text

Julien Salvi DevFest Stockholm 2025 󰐴 @jusalvi.bsky.social Thanks! Embrace the Compose world!