paint-brush
AndroidX Explainedby@Ansari
1,916 reads
1,916 reads

AndroidX Explained

by Mustufa AnsariNovember 22nd, 2019
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

AndroidX is a new way of organizing support libraries introduced by Google. It is a continuation of Android support libraries. All support libraries are built for backward compatibility. The migration to AndroidX in Android Studio is quite easy. You need to update your Android Studio to the latest version — as I write this, it’s studio version 3.5.2+ or above. You can find the complete mapping of all support libraries in your build.gradle.properties file here. You must have Android Studio 3.2+.

Company Mentioned

Mention Thumbnail
featured image - AndroidX Explained
Mustufa Ansari HackerNoon profile picture

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.