Migrating Android Studio Projects To Android X - Tech Projects/Documentations
image

Migrating Android Studio Projects To Android X

Migrating to the android x namespace:

Case study: Android applications built with java.

Author: Eze-Odikwa Tochukwu Jed

Introduction:

The android x namespace is a major improvement to the original android support library which is no longer supported and fully replaced by android x itself. it is also an open source solution which is used for development, tests, packaging, versioning and releasing libraries within android jetpack. To use android x in a new project you need to set the compile SDK to Android 9.0 (API level 28) or higher.

For official docs on the android x library mappings click HERE.

Migrating your projects to android x

Step by step procedure for migrating your android studio project to android x

Step 1: Update SDK version to 28 in build.gradle

If you use an older SDK version before migrating to Android x, then you’re going to have a bad time because you will need to address the namespace changes and the API changes from API level 26 or 27 in your codebase, after these issues are resolved you can go ahead and click the migrate button > migrate to android X. Ensure also that your project is backed up before proceeding.

Step 2: Enable Jetifier

Jetifier migrates your third-party dependencies to use AndroidX. It’ll actually change the flight code of the dependencies to be compatible with your project that’s using AndroidX.

Eg;

android.support.v7.widget.AppCompatImageView

//will change to

androidx.appcompat.widget.AppCompatImageView

//after migrating to android x

Jetifier won’t migrate your source code and generated code. To enable Jetifier, just follow the following steps.

Add the following to your gradle.properties file:

android.useAndroidx = true

android.enablejetifier = true

When you do code auto completion and import libraries, you import the Androidx version of that library instead of the old Android Support Library version.

Step 3: Update Dependencies

In some instances third party libraries won’t be automatically migrated to android x, you might need to check for compatibility issues.

Duplicate class errors: is a known bug that is associated with migrating your android studio project to android x it is the result of bad dependency matching, duplicate dependencies in a dependency tree and a dependency with bugs. it is also an indication that you are halfway with migrating your project to android x. To resolve this bug check your project dependencies and dependency tree.

Eg;

Implementation 'com.jjoe64:graphview:4.2.1'

//Causes duplicate class error update it to

Implementation 'com.jjoe64:graphview:4.2.2'

References        

developer.android.com/topic/libraries/support-library. (2021). Support Libraries in android

developer.android.com/jetpack/androidx. (2022). Android x overview

leave your comment


Your email address will not be published.

Uploading