What is AndroidX?
AndroidX - Android Extension Library
From AndroidX documentation
We are rolling out a new package structure to make it clearer which packages are bundled with the Android operating system, and which are packaged with your app's APK. Going forward, the android.* package hierarchy will be reserved for Android packages that ship with the operating system. Other packages will be issued in the new androidx.* package hierarchy as part of the AndroidX library.
Need of AndroidX
AndroidX is a redesigned library to make package names more clear. So from now on android hierarchy will be for only android default classes, which comes with android operating system and other library/dependencies will be part of androidx (makes more sense). So from now on all the new development will be updated in androidx.
com.android.support.** : androidx.
com.android.support:appcompat-v7 : androidx.appcompat:appcompat
com.android.support:recyclerview-v7 : androidx.recyclerview:recyclerview
com.android.support:design : com.google.android.material:material
Complete Artifact mappings for AndroidX packages
AndroidX uses Semantic-version
Previously, support library
used the SDK version but AndroidX uses the Semantic-version
. It’s going to re-version from 28.0.0 → 1.0.0.
How to migrate current project
In Android Studio 3.2 (September 2018), there is a direct option to migrate existing project to AndroidX
. This refactor all packages automatically.
Before you migrate, it is strongly recommended to backup your project.
Existing project
- Android Studio > Refactor Menu > Migrate to AndroidX...
- It will analyze and will open Refractor window in bottom. Accept changes to be done.
New project
Put these flags in your gradle.properties
android.enableJetifier=true
android.useAndroidX=true
Check @Library mappings for equal AndroidX package.
Check @Official page of Migrate to AndroidX
What is Jetifier?
Bugs of migrating
- If you build app, and find some errors after migrating, then you need to fix those minor errors. You will not get stuck there, because that can be easily fixed.
- 3rd party libraries are not converted to AndroidX in directory, but they get converted at run time by Jetifier, so don't worry about compile time errors, your app will run perfectly.
Support 28.0.0 is last release?
From Android Support Revision 28.0.0
This will be the last feature release under the android.support packaging, and developers are encouraged to migrate to AndroidX 1.0.0
So go with AndroidX, because Android will update only androidx package from now.
Further Reading
https://developer.android.com/topic/libraries/support-library/androidx-overview
https://android-developers.googleblog.com/2018/05/hello-world-androidx.html
Based on the documentation:
androidx is new package structure to make it clearer which packages are bundled with the Android operating system, and which are packaged with your app's APK. Going forward, the android.* package hierarchy will be reserved for Android packages that ship with the operating system; other packages will be issued in the new androidx.* package hierarchy.
The re-designed package structure is to encourage smaller and more focused libraries. You find details regarding the artifact mappings here.
There are support libraries (containing component and packages for backward compatibility) named "v7" when the minimal SDK level supported is 14, the new naming makes it clear to understand the division between APIs bundled with platform and the libraries for app developers which are used on different versions of Android. You can refer to official announcement for more details.