Skip to content

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 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.support references to androidx. 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.support libraries.
    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 all android.support references to androidx:

    • Cordova: Volt MX has provided you the control of the cordova android build 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 cordova android build folder. For more information about the details of this resolution, click here.
    • ReactNative: Because you already have control of the react-native android project 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.support references in NFIs and Android manifest tag entries added through Volt MX Iris.
      Resolution: You must manually change all android.support references, and then build the application again. For more information about how to convert android.support references by using the Jetifier tool, click here(#convert-references-by-using-jetifier-tool). For more information about the mapping of namespaces from android.support to androidx, click here.

Convert android.support References by using Jetifier Tool

  1. Search the JavaScript files, Android Manifest tag entries, and XML files for the occurrence of the android.support string.
  2. The Jetifier tool only accepts a .JAVA or .XML file as input. In accordance with this, copy all the android.support strings that you find to one file. For example, supportstrings.java.
  3. 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.

  1. Go to the extracted folder > bin folder, and then run the following command to get androidx equivalent references of android.support in the output file.
    -i: The input file with android.support references.
    -o: The output file where the equivalent androidx references are to be saved.

``` jetifier-standalone -i -o

```

  1. You can now use the contents of the androidxstrings.java file to replace all the android.support references.