katzer/cordova-plugin-email-composer

Switch from android support library to androidx?

shankari opened this issue ยท 21 comments

Android is deprecating the support libraries in favor of androidx
https://developer.android.com/jetpack/androidx/

The newest version of cordova also supports androidx
https://cordova.apache.org/announcements/2020/06/29/cordova-android-9.0.0.html

It is not possible to mix and match the androidx and support libraries.

A lot of the Android supported plugins are still using the old support libraries which can not build when using the AndroidX support libraries.

This plugin imports the android support libraries in exactly one place
https://github.com/katzer/cordova-plugin-email-composer/search?q=android.support&unscoped_q=android.support

I am happy to make the trivial change (to https://developer.android.com/reference/androidx/core/content/FileProvider?hl=en) and submit it. Note that since this is an incompatible change, it would need to be a major revision.

Please let me know if I should submit the PR.

Please! I'm in the same boat. It's unclear whether the update will be accepted: despite being the official email-composer library for ionic-cordova, it hasn't had been tagged since January 2019. It hasn't even been updated since September 2019. I would love this update, though! Please consider making this change, @katzer! It would be so simple yet it would be SO helpful! :)

When using cloud build services, this plugin will now cause builds to fail because it lacks androidx support and all cloud build services pull from npm. If this is fixed could PLEASE push a new release out to npm.

capc0 commented

@katzer friendly bump :)

I forked the plugin to make the necessary change in my project, but after that I discovered jetifier, a simpler way to fix the issue until plugin will be updated.

@sertal70 Thank you for the suggestion. How did you get it working? I ran this, and it did not seem to help.:

yarn add -D jetifier
npx jetifier
cordova-plugin-androidx-adapter

To double check whether I'm having the same issue as others in this thread: Within Android Studio, when I try to run my app, I get this build error:

error: package android.support.v4.content does not exist
import android.support.v4.content.FileProvider;

@ersimont if I remember correctly, jetifier modifies plugin in the node_module directory, so you need to update your Android project also. In my case I used capacitor so the command is nix cap sync, check Cordova documentation on how to perform this task in that framework.

In my config I added

<platform name="android">
    <preference name="android-multiDexEnabled" value="true" />
    <preference name="AndroidXEnabled" value="true" />
    <preference name="JetifierEnabled" value="true" />
</platform

  <plugin name="cordova-plugin-androidx-adapter" spec="1.1.3" />
  <plugin name="cordova-plugin-email-composer" source="npm" spec="0.9.2" />

The problem that I was originally having was with cordova-plugin-push using the wrong fcm library and once I fixed that, it worked perfectly.

Can anyone share the status of this?
Was this fixed?
was a PR sent?
is there a working branch to fix this?
I'm not sure I understand how to use jetifier with Cordova - the above config doesn't seem to do anything and I haven't found this in the docs.
If anyone has a simple solution to androidX upgrade it will be great.

I used:

    <preference name="AndroidXEnabled" value="true" />
    <preference name="android-multiDexEnabled" value="true" />

  <plugin name="cordova-plugin-androidx-adapter" spec="1.1.3" />
  <plugin name="cordova-plugin-email-composer" spec="0.9.2" />

Plugins are no longer saved in the config.xml file, are you using cordova or something else?

In any case, if anyone is interested I can confirm I can get the same functionality I needed using the social-sharing plugin.
This plugin has a way to send mail, and you can specify the file names using the df: prefix and send a base64 files.
That plugin also supports anrdoidX and seems to be well maintained.
I've just made the switch in order to be able to easily migrate to androidX, I was already using this plugin for file sharing so I didn't need to introduce it.
Good luck! :-)

I'm using Voltbuilder which is, essentially, a cloud hosted version of cordova. I only use this plugin for debugging. I hijack console.log so that when I'm out in the "wild" I (and others) can capture all the output I need/want and view it on a page or send it to myself. In production versions, this is removed.

Hi all,
Google is moving everything to AndroidX and this can't be ignored anymore.
This issue was open in 2020, there's no contribution from authors and no one assigned to it.

Does anyone know if this plugin is in active development?
Or should we have to treat it as deprecated?

Thanks
D.

Social sharing plugin has all the required functionality as far as I needed, I removed this plugin and migrated to it fully...

I only use this plugin during the debug process (I hijack the console.log functionality, save the log output and email it to myself... allows me to debug in the wild/untethered).

I have this working with the following plugin:

  <plugin name="cordova-plugin-androidx-adapter" spec="1.1.3" />

@ppetree would this plugin work in AndroidX by merely installing cordova-plugin-androidx-adapter ?

@sertal70 have you fixed this issue? How?

I'm a maintainer of this repo and I can make the necessary fix if you guys submit a PR

I mean, I can simply add at plugins.xml

<dependency id="cordova-plugin-androidx-adapter" version="^1.1.3" />

@jfoclpf I simply used jetifier to update the current plugin installation in my project.

Rather than a fix, it is a patch, so no PR sorry.

Someone skilled at Android development should make all necessary changes in the plugin codebase to use AndroidX libraries. Maybe jetifier can help because one can review all the fix it makes.

@ppetree how did you solve this issues?

Explanation given at documentation to solve the problem: 5a62f6d

@ppetree how did you solve this issues?

As I had documented earlier, it was in going to a later version of the push plugin and then adding jetifier.

Thank you, it is indeed already well documented in the repo what one should do, when facing issues with AndroidX.