I am reading about a room library of Android. I see they changed package android
to androidx
. I did not understand that. Can someone explain, pleas
This article Android Jetpack: What do the recent announcements mean for Android’s Support Library? explains it well
Today, many consider the Support Library an essential part of Android app development, to the point where it’s used by 99 percent of apps in the Google Play store. However, as the Support Library has grown, inconsistencies have crept in surrounding the library’s naming convention.
Initially, the name of each package indicated the minimum API level supported by that package, for example, support-v4. However, version
26.0.0
of the Support Library increased the minimum API to 14, so today many of the package names have nothing to do with the minimum supported API level. When support-v4 and the support-v7 packages both have a minimum API of 14, it’s easy to see why people get confused!To clear up this confusion, Google is currently refactoring the Support Library into a new Android extension library (AndroidX) package structure. AndroidX will feature simplified package names, as well as Maven groupIds and artifactIds that better reflect each package’s content and its supported API levels.
With the current naming convention, it also isn’t clear which packages are bundled with the Android operating system, and which are packaged with your application’s APK (Android Package Kit). To clear up this confusion, all the unbundled libraries will be moved to AndroidX’s androidx.* namespace, while the android.* package hierarchy will be reserved for packages that ship with the Android operating system.
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.
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
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.
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
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
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.
https://developer.android.com/topic/libraries/support-library/androidx-overview
https://android-developers.googleblog.com/2018/05/hello-world-androidx.html
androidx
will replace support library
after 28.0.0
. You should migrate your project to use it. androidx
uses Semantic Versioning. Using AndroidX
will not be confused by version that is presented in library name and package name. Life becomes easier
[AndroidX and support compatibility]
I got to know about AndroidX from this Android Dev Summit video. The summarization is -