The Truth of Migrating to AndroidX (Android Jetpack) Guide to Developer

This year, Google announced at its developer event Google I/O the creation of a new set of libraries, tools and architectural guidance for Android: AndroidX, better known as Android Jetpack. But what is Android Jetpack? It is a series of unbundled libraries that are not linked to any particular version of Android, which allows developers to include the newest features in older versions of Android.'

What's new in Android Jetpack

In addition, Android Jetpack helps perform more tasks, reducing the number of lines of code, by providing the repeating plate to handle repetitive tasks. Its components can be grouped into four categories: Foundation, UI, Architecture and Behavior. Also, Android Jetpack brings 5 new components:

Work Manager: A task scheduler.

Navigation: This component enables you to design, edit and adjust the navigation of your application.

Paging: Divides the data to be loaded in parts, reducing the waiting time.

Slices: They show a fragment of the content of your application on Google, you can see a great variety of static and interactive content about it.

Android KTX: It’s a collection of modules consisting of extensions that optimize the APIs of the Android platform for Kotlin.

How to update to AndroidX

Before even thinking about migrating to AndroidX, you must update all your current support libraries to their latest versions. To change old artifacts into new ones will only require changing the names of the packages. This means, in most cases, being in version v28.0.0 of the support libraries. However, some libraries use other version schemes: Android KTX must be updated to v0.3.

This preparation is excellent for discovering parts of your base code that cannot work with the updated libraries and so you can proceed to update without problem.

According to the official Google guide to update, you have to download the canary version of Android Studio, although you can keep the stable and canary versions on your machine. Open your project in the Canary version and then go to the Refactor menu and select Refactor to AndroidX... now Android Studio will scan your project and change your libraries to the new AndroidX structure.

This is risky because in several cases the projects are completely broken, the imports aren´t mapped correctly, and it is possible that you be forced to do a lot of manual work. In other cases, most of the changes may work fine, but you may have problems, such as having the old library androidx.app.Fragment in the code with the old support.v4.Fragment as the imported class type of "errors". Fortunately, these types of errors are easy to fix.

Problems with the migration to AndroidX

The next step, which should be done automatically by Android Studio, was to change / add dependencies in the build.gradle modules.

For its part, jetifier is a useful tool that automatically migrates its dependencies to AndroidX at the time of compilation, saving the need to import each dependency that you use to have an AndroidX version before you can migrate. However, the jetifier only works on packaged devices, it doesn´t work with source code. You will have to update it manually.

It is advisable to use a small script that allows you to be sure that all package names were converted to Android Jetpack. Fortunately Google provides an old csv file to the new package names that will be very useful to program that script.

Conclusion

For now, the artifacts of the support library are in disuse and all future development is being done in AndroidX, so this migration is inevitable. For now, there are no plans to abandon the support libraries, so if a component is available for the support library and Android Jetpack at the same time, you can still choose which implementation you want to use. However, version 28.0.0 will be the latest version of android.support. After that, you will have to update to the AndroidX namespace and architecture.

0 Comment(s)

Comment on it

AttachFiles,Zip etc

RecordFrom Desktop

RecordFrom Webcam

Preview

Enter captcha to proceed

Unable to start Java!! Mr. Nerd figure out why...

We have detected you are using Google Chrome and might be unable to use the Java plugin from this browser. Starting with Version 42 (released April 2015), Chrome has disabled the standard way in which browsers support plugins. More info

Chrome Version Support

Starting with Chrome version 45, NPAPI is no longer supported for Google Chrome. For more information, see Chrome and NPAPI (blog.chromium.org).

Firefox and Microsoft Internet Explorer are recommended browsers for websites using java applets.

Chrome Version Support

Starting with Chrome version 45, NPAPI is no longer supported for Google Chrome. For more information, see Chrome and NPAPI (blog.chromium.org).

Firefox and Microsoft Internet Explorer are recommended browsers for websites using java applets.

Chrome Version Support

Starting with Chrome version 45, NPAPI is no longer supported for Google Chrome. For more information, see Chrome and NPAPI (blog.chromium.org).

Firefox and Microsoft Internet Explorer are recommended browsers for websites using java applets.

Unable to start Java!! Mr. Nerd figure out why..

We have detected that Java plugin is not installed/enabled on your browser. Unfortunately some of our below listed tools require Java plugin:

Desktop recorder.

Error Screen capture.

Time Tracker.

To use our product please click on the link to install/Detect Java plugin.

You have exceeded the maximum number of characters allowed for a comment without sign in.Either enter Content Or Record

Your Post will be visible in the listing once it has been approved by the administrator.