Search code examples
androidandroid-studioandroidx

Migrating to AndroidX does nothing on Android Studio


I want to migrate my existing project to androidx. For that, I am clicking Refactor -> Migrate to AndroidX, and it asks me to backup my project, after doing that Android Studio searching and showing me Refactoring Preview. And when I click to Do Refactor, nothing happens. Neither trying to migrate, nor giving any error. I am using latest gradle version.

compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
    applicationId "com.dummy"
    minSdkVersion 21
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

gradle.properties: (There is only one line)

org.gradle.jvmargs=-Xmx1536m

Solution

  • You should add below in your gradle.properties section.

    android.useAndroidX=true
    # Automatically convert third-party libraries to use AndroidX
    android.enableJetifier=true
    

    Read official documents about Migrating to AndroidX

    FYI

    You can upgrade tools.build:gradle version

     dependencies {
            classpath 'com.android.tools.build:gradle:4.0.1'
    

    And

    android {
        compileSdkVersion 30
        defaultConfig {
            applicationId "####"
            minSdkVersion 23
            targetSdkVersion 30
    

    Then Restart IDE