It’s frustrating to know there are still so many Android projects that are not using Jetpack, even the projects created after the Jetpack released.
The original title that came up with me is
Start your new Android project with Jetpack (AndroidX)
But after trying to create a new project with Android Studio (3.5.1), I found out that the option of
Use androidx.* artifacts is checked by default, and we cannot uncheck it. It seems like using Jetpack is not just a recommendation but a requirement for a new project now.
So let’s talk about migrating an existing project to AndroidX.
Jetpack is a suite of libraries, tools, and guidance to help developers write high-quality apps easier. These components help you follow best practices, free you from writing boilerplate code, and simplify complex tasks, so you can focus on the code you care about.
According to the description from Jetpack, there are so many components that we can use to accelerate our development, and there is a sample project illustrating best practices with Jetpack.
I would like to talk about some of them in future posts.
You may ask
I don’t need those fancy new things, do I still need to migrate?
The answer is still positive if you are using Support Library.
You can continue to use the support library. Historical artifacts (those versioned 27 and earlier, and packaged as android.support.*) will remain available on Google Maven. However, all new library development will occur in the AndroidX library.
So the migration to AndroidX is an inevitable process you need to do as soon as you can for most of the projects.
There is an official page of Migrating to Android.
- Refactor > Migrate to AndroidX from the menu bar of Android Studio
- Do some manual mappings if something went wrong
If you still have issues after the steps above, you may need to update dependencies to the version that supports AndroidX.
Not that hard, right?
Let’s do it
Let’s do it right away for your projects, even your company’s, and I hope this post can help you to convince your superior if you have to.
Where to Go From Here
A version that is binary equivalent to
androidx.*1.0.0. We can solve some issues related to the update of Support Library before migrating to AndroidX. ↩