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.
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 documentation, these two flags set automatically to true after refactoring in your
gradle.properties
.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.