AndroidX Behavioral Changes
AndroidX is the new and enhanced version of the Android Support Library. Android Pie is the final release for android.support; all new feature releases will be available in androidx-packaged.
In this document, we will explain about Volt MX Iris's AndroidX-supported plugins and the Jetifier flags that are automatically added in the gradle.properties file. Furthermore, we will discuss about the various issues that arise while you try to migrate your project to AndroidX and how to resolve these issues.
This document contains the following sections:
- Automatic addition of Jetifier flags in the gradle properties file
- Issues while migrating to AndroidX and their resolutions
- Convert android.support references by using Jetifier tool
Automatic Addition of Jetifier FlagsĀ in gradle properties File
From V9 SP2, Volt MX has released AndroidX-supported plugins. As part of these plugins, the following Jetifier flags are specified in the gradle.properties file:
android.useAndroidX=true: The Android plugin uses the appropriate AndroidX library, instead of using a Support Library.android.enableJetifier=true: The Android plugin automatically migrates existing third-party libraries (such as, JAR and AAR) to use AndroidX by rewriting their binaries.
Important: After both these flags have been set, if the native Android project contains any references to the Android Support Library in its sources files and manifest entries, the command-line build will fail due to an Android Tools issue.
Note: With Android Studio 3.2 and later, you can migrate an existing project to AndroidX by selecting Refactor > Migrate to AndroidX from the menu bar. This action converts all
android.supportreferences toandroidx. For more information about how to migrate an existing project to AndroidX, click here.
Issues while Migrating to AndroidX and their Resolutions
While consuming VoltMX's AndroidX-supported plugins and migrating your project to AndroidX, you must manually replace any android.support references in the following scenarios:
-
The plugins of a Cordova project or a React Native project that use
android.supportlibraries.
Resolution: In this scenario, you can use the following Cordova and ReactNative project folders and click the Migrate to AndroidX option in Android Studio to convert allandroid.supportreferences toandroidx:- Cordova: Volt MX has provided you the control of the cordova
androidbuild folder (which gets generated during build time) to make the necessary changes. You can manually customize the Cordova-generated Android project, bundle this customized project, and then check in the modified cordovaandroidbuild folder. For more information about the details of this resolution, click here. - ReactNative: Because you already have control of the react-native
androidproject folder, you can directly integrate the AndroidX-migrated project. This folder gets integrated into the Volt MX Iris project as a library project during build time. - For
android.supportreferences in NFIs and Android manifest tag entries added through Volt MX Iris.
Resolution: You must manually change allandroid.supportreferences, and then build the application again. For more information about how to convertandroid.supportreferences by using the Jetifier tool, click here(#convert-references-by-using-jetifier-tool). For more information about the mapping of namespaces fromandroid.supporttoandroidx, click here.
- Cordova: Volt MX has provided you the control of the cordova
Convert android.support References by using Jetifier Tool
- Search the JavaScript files, Android Manifest tag entries, and XML files for the occurrence of the
android.supportstring. - The Jetifier tool only accepts a .JAVA or .XML file as input. In accordance with this, copy all the
android.supportstrings that you find to one file. For example,supportstrings.java. - Click here to download the Jetifier zip file from the Install jetifier section, and then extract it.
Note: Your must install Java version 1.8 in your system to run the Jetifier standalone tool.
- Go to the extracted folder >
binfolder, and then run the following command to getandroidxequivalent references ofandroid.supportin the output file.
-i: The input file withandroid.supportreferences.
-o: The output file where the equivalentandroidxreferences are to be saved.
```
jetifier-standalone -i
```
- You can now use the contents of the
androidxstrings.javafile to replace all theandroid.supportreferences.