Here's my story: I've migrated my app to AndroidX because I needed some new features from a library I found online.
Problem: I'm currently running into some issues because I now need to develop a plugin for Cordova that implements a part of that app.
I generated a .arr file with my library & tried to make a Cordova plugin which acts as a interface to use the library. But when I try to use cordova-plugin-camera
with my plugin, which uses AndroidX, I get errors: duplicate imports because cordova-plugin-camera
uses the support library.
Solution: I've removed the dependencies to AndroidX & replaced them with the old support library.
Question: Is it a good idea to switch to AndroidX right now or am I better off keeping the support library ? Did I implement something wrong ? What did you choose for your projects ?
I've created a couple of utility plugins to assist with AndroidX migration in Cordova Android projects:
I created these as a generic solution for AndroidX support in my existing plugins which reference the Android Support Library, e.g. cordova-diagnostic-plugin against which AndroidX support issues has been raised.
This means that by installing both of these plugins in a Cordova project that already contains plugins which reference either the legacy Support Library names and/or the AndroidX names, the build will now succeed.
For example, try this test case:
cordova create test && cd test
cordova platform add android@8
cordova build android
=> build succeeds
cordova plugin add cordova.plugins.diagnostic@5
cordova build android
=> build succeeds
cordova plugin add cordova-plugin-androidx
cordova build android
=> build fails
cordova plugin add cordova-plugin-androidx-adapter
cordova build android
=> build succeeds