Before you go, check out these stories!

0
Hackernoon logoAndroidX Explained by@Ansari

AndroidX Explained

Author profile picture

@AnsariMustufa Ansari

📱Mobile Application Developer 🎓Keen Learner 🎓Graduate 🎧Love Music 🎓 Tech Enthusiast!

AndroidX is a new way of organizing support libraries introduced by Google. Basically, AndroidX. is introduced along with Android Jetpack because jetpack comprises the 

androidx.*
 package libraries.

As in every Android project you build on Android Studio, you must have seen these support libraries in your 

build.gradle
 file starting with 
com.android.support
.

  • com.android.support:appcompat-v7
  • com.android.support:recyclerview-v7

But after AndroidX came along, these libraries have a starting package like androidx. instead of com.android.support.

  • androidx.appcompat:appcompat
  • androidx.recyclerview:recyclerview

Aren’t they simple looking?😁

You can find the complete mapping of all support libraries here.

After reading above, you probably came up with these questions.

  1. What if you converted your existing project into AndroidX so that it would be compatible?
  2. How do I convert an existing project into AndroidX?

Answer 1:

YES. All support libraries are built for backward compatibility so AndroidX is a modern way of representing support libraries. If I am not wrong, AndroidX is just an intuitive naming convention. You can say that AndroidX is a continuation of Android support libraries.

Answer 2:

First, you need to update your Android Studio to the latest version — as I write this, it’s studio version 3.5.

You must have Android Studio 3.2+ or above.

In the latest versions of Android Studio — I am talking about 3.+ versions — the migration to AndroidX is quite easy.

All you need to do is just open your Android Studio.

1. Go to Refactor > Migrate to AndroidX

2. After selecting this, Android Studio will ask you if you want to save a backup copy of your project in a .zip file — just to make your life easier. In case of any problems, you can get your project back.

According to the documentationthese two flags set automatically to true after refactoring in your 

gradle.properties
.

a)
android.useAndroidX=true:
This will ensure that Android plugins use the appropriate AndroidX library instead of support libraries.

b)

android.enableJetifier=true:
This will automatically convert third party libraries to AndroidX.

Thanks for your time. Hope you got some new info.

Here are some of my other useful articles.









Author profile picture

@AnsariMustufa Ansari

Read my stories

📱Mobile Application Developer 🎓Keen Learner 🎓Graduate 🎧Love Music 🎓 Tech Enthusiast!

Tags

Join Hacker Noon

Create your free account to unlock your custom reading experience.