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, please?
implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"
Even this is available with the android
package also.
implementation "android.arch.persistence.room:runtime:$room_version"
annotationProcessor "android.arch.persistence.room:compiler:$room_version"
androidx
instead of android
?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