A Journey of Migrating to Android Jetpack Compose Part I
Part I: project setup
I am writing down my journey of migrating an existing app (built with traditional Android View system) to an Android Jetpack Compose app. And my plan is to replace the existing screens one by one, and at the same time observe app crash rate and app performance…until a point I want to stop or make it a fully Jetpack Compose Android App.
Be honest to myself is the key of writing this article. (I don’t want to present to like it, just because everyone is talking about Jetpack Compose.)
I will write down the confusion if I feel so, and also the joy if I am really enjoying it during this journey.
OK, here I start…
Love Animal — Animal Crossing New Horizons companion app
By the way, this app was built during the lock down time at 2020 — for my own benefit — when I was obsessed with Animal Crossing New Horizons Nintendo Switch game.
Love Animal app is simple, especially the Settings screen which was built by using PreferenceFragmentCompat — the traditional way of building a Settings screen in Android.
So my first step is to build the Settings screen by using Jetpack Compose.
Step 1, project setup
Download Android Studio Canary Version
For the best experience developing with Jetpack Compose, you should download the latest canary version of Android Studio Preview.
— Jetpack Compose team
Step 2, Kotlin version
We need to use Kotlin version 1.4.30+, I use 1.4.31.
// project level
ext.kotlin_version = ‘1.4.31’
Step 3, enable Compose
Step 4, target Java 8
Step 5, setup module dependencies
Step 6. Android gradle version
After sync project and rebuild, now I am able to compile the project with Jetpack Compose setup. Even everything else is still old, but which means this project is at good position to going forward.
Setting up Jetpack Compose on an existing Android app is easy, I played around with the built app, didn’t see crash or bug.
I will be heading to migrate the Settings screen now.