androidandroid-architecture-componentsandroid-jetpackandroidx

What is AndroidX?


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"

Solution

  • 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

    image

    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

    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