Android App, Android Development

Hello AndroidX!

Last year, Google released the new AndroidX (Android Extension) dependencies. AndroidX is a rebrand of the previous Android support libraries. Similar to the support library, it provides backward-compatibility across android devices.

If you have not migrated to AndroidX, then you will be using the Android support libraries in your Android projects. e.g.

implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'

These support libraries have been around since 2011 and over time have become pretty confusing especially for new Android developers trying to catch up. e.g. naming different support libraries with -v7:28.0.0,  -v4:28.0.0, -v13:28.0.0 was inconsistent and could confuse a lot of people.

With Android support libraries, all the libraries must have the same version number as well. Because of this, trying out the code snippet below would make gradle hint an error.

implementation 'com.android.support:appcompat-v7:27.1.0' 
implementation 'com.android.support:design:27.0.0' 
implementation 'com.android.support:support-v4:26.0.0'

AndroidX is an improvement on the previous Android support libraries. They provide simplified package names.

However, the com.android... packages still exist, but there have been left for default classes that are shipped with the OS. The last version of the support library is 28.0.0. They will be discontinued so after this version, you have to use the AndroidX dependencies.

 

Things you’d need to do before migrating

  • Back up your project files: If you are trying to migrate a very heavy android project, something might go wrong. Because of this, it’s important that you back up your project files to be safe.
  • Be up to date on all support library artifacts.
  • Be up to date with gradle.
  • Make changes all across. Merging could be painful if a dev branch now uses AndroidX and a WIP feature branch is still on support libraries.

 

If you are running Android studio 3.2.1 and above, there is a built-in feature to help migrate your project to AndroidX.

All you need to do is go to Refactor > Migrate to AndroidX.

That’s it!

To see the mapping of old artifacts to the AndroidX artifacts, click here.

 

Spread the love

Leave a Reply

Your email address will not be published. Required fields are marked *