Skip to content Skip to sidebar Skip to footer

Ionic Android Build Error After Migrating To Androidx

I am working on an ionic 3 project.i had to migrate to androidx due to a sudden build issue. I created the android platform with cordova-android@8.0.0 version and i did the needful

Solution 1:

The errors are arising because your Android project contains Java source code (presumably in the form of Cordova plugins) which references the Android Support Library but you have enabled AndroidX in your project. AndroidX and the Android Support Library cannot live side-by-side in the same Android project - doing so will lead to build failures such as this. From your project.properties it can been seen that the Support Library is being pulled in as a Gradle dependency (e.g. cordova.system.library.3=com.android.support:support-v4:28.+).

AndroidX (Jetpack) is the successor to the Android Support Library. Note that AndroidX is now used by the latest versions of Play Services & Firebase libraries. The Support library is used by many existing plugins such as cordova-plugin-firebase.

To resolve this issue, add the following two plugins your Cordova project:

  • cordova-plugin-androidx to enable AndroidX in the Android project.
  • cordova-plugin-androidx-adapter to dynamically patch the source code of any plugins using the Support Library to use the AndroidX equivalents and to patch the Gradle config to replace Android Support Library references with AndroidX equivalents.

For a working example of this in a test project, see my comment on this Github issue.

Note: if you are using cordova-plugin-firebase and encountering errors, you can instead use my fork of that plugin which is published as cordova-plugin-firebasex and is fixed to resolve issues caused by the new Firebase SDK. Here's the safest way to migrate:

rm -Rf platforms/android
cordova plugin rm cordova-plugin-firebase
rm -Rf plugins/ node_modules/
npm install
cordova plugin add cordova-plugin-firebasex
cordova platform add android

Post a Comment for "Ionic Android Build Error After Migrating To Androidx"