Migrating to AndroidX

What is AndroidX?

AndroidX is a major improvement to the original Android Support Library, which is no longer maintained. androidx packages fully replace the Support Library by providing feature parity and new libraries.

Android old artifacts and package names were a confusing mess, so in the long run this is a great move. In the short-term, though, upgrading requires extensive changes to your code-base if migration is not handled carefully.

Why migration is Needed?

The support library artifacts are being deprecated and all future development is going into AndroidX, so there’s no avoiding this migration.

How to start migration?

Before you begin to flirt with the idea of migrating to AndroidX, you should be up-to-date on the latest versions of all your current support library artifacts. That way the leap from old to new artifacts should only require changing package names.

Theoretically, migration should be as easy as running the "Migrate to AndroidX" tool in Android Studio. If that works for you, then fantastic!

Migration Failure

Unfortunately, Migration can be failed it in multiple ways:

  • The maven coordinates for the AndroidX artifacts were often out-of-date (referring to alpha builds instead of the latest stable builds).
  • It did not actually find/replace all the package references that needed updating.
  • It made extraneous changes to our codebase — it should’ve only touched import statements, but instead it unnecessarily modified other references as well.

Fixing the maven coordinates was easy — either look up the most recent version on Google's repository, or use gradle-versions-plugin to automatically detect the latest artifacts.

The more daunting task is to ensure that you had actually converted all the package names. Luckily, Google provides a csv file mapping old to new package names.

Conclusion

AndroidX is a major improvement to the original Android Support Library. Like the Support Library, AndroidX ships separately from the Android OS and provides backwards-compatibility across Android releases.

Need more details?
Contact Us