How do I migrate an Android Studio 3.2 existing project to Android X?

Please Share On:

AndroidX is launched. Now, you want to migrate your existing android project to AndroidX so that your application will support the latest device. You don’t know how to do it. The process is pretty simple.

Step 1: Open your Android Studio’s existing project.

Step 2: Click Refactor -> Migrate to AndroidX

Step 3: I faced the following error. If you faced the same error then follow my steps to fix this error first.



Step 4: Press OK and open your AndroidManifest.xml file to change your target SDK.

Step 5: Change your old android SDK version to 28 and sync now, which is located at the top right corner. You need to change your target Android SDK version every time you have a new version available.

    android:minSdkVersion = "14"
    android:targetSdkVersion = "28"

Step 6: Open your build.gradle(Module:Mobile) and change compileSdkVersion, buildToolsVersion and targetSdkVersion to latest version.

Step 7: Change all compile dependencies into the latest “implementation” and sync now.

Existing Version:

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.google.firebase:firebase-core:11.0.4'
    compile 'com.google.firebase:firebase-crash:11.0.4'
    compile 'com.google.firebase:firebase-auth:11.0.4'
    compile 'com.google.firebase:firebase-messaging:11.0.4'
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:design:25.3.1'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.google.android.gms:play-services:11.0.4'
    compile 'com.google.android.gms:play-services-ads:11.0.4'
    compile 'com.google.android.gms:play-services-auth:11.0.4'
    compile 'com.google.android.gms:play-services-gcm:11.0.4'
}

AndroidX version:

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    testImplementation 'junit:junit:4.13'
    implementation 'com.google.firebase:firebase-core:17.2.2'
    implementation 'com.google.firebase:firebase-crash:16.2.1'
    implementation 'com.google.firebase:firebase-auth:19.2.0'
    implementation 'com.google.firebase:firebase-messaging:20.1.0'
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.multidex:multidex:2.0.1'
    implementation 'com.google.android.gms:play-services-identity:17.0.0'
    implementation 'com.google.android.gms:play-services-gcm:17.0.0'
    implementation 'com.google.android.gms:play-services-ads:18.3.0'
    implementation 'com.google.android.gms:play-services-auth:17.0.0'
}

Step 8: Right Click build.gradle(Project: …) -> Refactor -> Migrate to Android X. And Do Refactor.

Step 9: Now, go back to Step 2 and try again to migrate to AndroidX.

Step 10: Now, you have successfully migrated your existing project to AndroidX. This is how I migrate my project to a new version.



Leave a Reply

Your email address will not be published. Required fields are marked *

Copyright @2023. All Right Reserved.


Social media & sharing icons powered by UltimatelySocial