Closed maxzirilli closed 3 years ago
It's crashing for me too on Android.
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.remove(ArrayList.java:503)
at de.appplant.cordova.emailcomposer.Impl.getDraft(Impl.java:90)
at de.appplant.cordova.emailcomposer.EmailComposer$4.run(EmailComposer.java:173)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
Seems to be an issue with this line of code: https://github.com/katzer/cordova-plugin-email-composer/blob/master/src/android/Impl.java#L90 removing an index that doesn't exist.
same issue here, even if there is no file attached to email and with basic email data. Using 'mailto'
Process: com.wkv.shippingcontrol, PID: 16457
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.remove(ArrayList.java:503)
at de.appplant.cordova.emailcomposer.Impl.getDraft(Impl.java:90)
at de.appplant.cordova.emailcomposer.EmailComposer$4.run(EmailComposer.java:173)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
Same issue here. Is there any fix yet?
Same here.
Device: Samsung A50 OS: Android 11 Context: Ionic/Angular/capacitor app
this.emailComposer.open(email);
Opening the mail client works on 2 devices:
Samsung S9+, Android 10 Samsung Tab A, Android 8.1
It crashes on
Samsung A50, Android 11
Android log:
E/AndroidRuntime: FATAL EXCEPTION: pool-3-thread-2 Process: de.minidat.windat, PID: 22863 java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.ArrayList.remove(ArrayList.java:503) at de.appplant.cordova.emailcomposer.Impl.getDraft(Impl.java:90) at de.appplant.cordova.emailcomposer.EmailComposer$4.run(EmailComposer.java:173) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:923)
Any idea how to fix this? Is this specific to Android 11?
Yes, the issue is specific to Android 11. I m still waiting for the fix :-(
Hey, @katzer Can you please look into this I am also having the same issue with the Android 11 app is crashing. Thanks in advance!
I'm a bit worried. This plugin seems abandoned
looks like, but i can't really find an alternative... :-(
seems like it's happen when no default app is selected for sending mails on the mobile. I took the getDrafts() Method from this file: Impl.java at 9f19ee5a8f27b18fce861f3412601dc84bf2f2e5 than the app opens the select menu for default mail app and it will work.
A dirty fix is to just return getFilledEmailIntent(params) in getDraft(), but it works.
Impl.java
Intent getDraft (JSONObject params) {
return getFilledEmailIntent(params);
}
A dirty fix is to just return getFilledEmailIntent(params) in getDraft(), but it works.
Impl.java
Intent getDraft (JSONObject params) { return getFilledEmailIntent(params); }
Thanks a lot Melf11! Your fix works great!
A dirty fix is to just return getFilledEmailIntent(params) in getDraft(), but it works.
Impl.java
Intent getDraft (JSONObject params) { return getFilledEmailIntent(params); }
It works! Thanks so much!
return getFilledEmailIntent(params);
That works for me but it shows all of the apps on the device, not just the email ones. Does anyone know a way to limit the options?
A dirty fix is to just return getFilledEmailIntent(params) in getDraft(), but it works.
Impl.java
Intent getDraft (JSONObject params) { return getFilledEmailIntent(params); }
Thanks Works pretty well
Thanks a lot @Melf11 ! Your fix save my life!
@Melf11 's fix and some other fixes that I tried, resulted in Android 11 successfully opening a draft email after prompting all possible apps, but any attachments failed to attach. This small change in the getDraft()
made it possible to show the correct apps in prompt and to successfully attach files.
The change:
return Intent.createChooser(draft, header)
instead of
return Intent.createChooser(targets.remove(0), header)
Not sure what possible side effects there may be, but I tested it on Android 11 & 10 target sdk 30.
Intent getDraft (JSONObject params) {
Intent draft = getFilledEmailIntent(params);
String app = params.optString("app", MAILTO_SCHEME);
String header = params.optString("chooserHeader", "Open with");
if (!app.equals(MAILTO_SCHEME) && isAppInstalled(app)) {
return draft.setPackage(app);
}
List<Intent> targets = new ArrayList<>();
for (String clientId : getEmailClientIds()) {
Intent target = (Intent) draft.clone();
targets.add(target.setPackage(clientId));
}
return Intent.createChooser(draft, header)
.putExtra(EXTRA_INITIAL_INTENTS, targets.toArray(new Parcelable[0]));
}
After testing it for a few days, it seems to be a stable fix, tested it on Android 11, 10 and older devices and all have the same expected behavior. Tested with multiple attachments and other use cases. Opened a pull request. #365
After testing it for a few days, it seems to be a stable fix, tested it on Android 11, 10 and older devices and all have the same expected behavior. Tested with multiple attachments and other use cases. Opened a pull request. #365
good work! thank you!
waiting for the fix pls
waiting for the fix pls
Check this pull request #365 and my posts above. I would appreciate some feedback from other testers, whether this fix is actually working for everybody or not.
@PetePrattis your fix worked for us. Thanks
The issue is Android 11 blocking queryIntentActivities()
I've made PR #368 to fix the issue. I only have limit range of devices for testing.
Try it, and comment if it doesn't work for any devices
@ebhsgit your pr #368 fixes the issue with Android 11, I tested it with Android 11, 10 and some older devices target sdk 30. Tested it for a variety of use cases, including multiple attachments. Everything worked as intended, we will implement this fix for our product if testing keeps going well, good job!
The issue is Android 11 blocking
queryIntentActivities()
I've made PR #368 to fix the issue. I only have limit range of devices for testing.Try it, and comment if it doesn't work for any devices
I tried on our app and I couldn't get it to work, not sure I missed something.
Removed the old plugin and installed it again using cordova's
cordova plugin add https://github.com/ebhsgit/cordova-plugin-email-composer#pr-Fix_361-Android_11_support
Checked the plugin.xml
and it seems to be the correct one with the fix. Installed on an Android 11 device and it did not work.
Already removed the entire platform and added it back again, nothing changes. If I missed anything, please let me know. Thanks in advance.
Edit: I tried to look for the new portion of code added in the plugin.xml
within platforms/android/app
but I couldn't find it.
Does anyone know where exactly would that piece of code go into after cordova generates it's files? I imagine it would be either in platforms\android\app\src\main\AndroidManifest.xml
or platforms\android\app\src\main\res\xml\config.xml
but it wasn't in either of those places.
@188599
Can you check the manifest.xml
to see if it has the queries
tag
<queries>
<intent>
<action android:name="android.intent.action.SENDTO" />
<data android:scheme="mailto" />
</intent>
</queries>
If not, then you are not using the fix
@ebhsgit I don't see any a manifest.xml
file anywere within the build, only the AndroidManifest.xml
and that one does not have the queries
tag at all.
Do you use cordova as well? If you do, would you mind walking me through the steps you took to make this work? I'm certain I have the right plugin, because like I said the plugins\cordova-plugin-email-composer\plugin.xml
does have the changes made by you, so it's something wrong in the build process that's not generating the proper tags in the xml file.
Edit: Finally figured out what the problem was.
Had to change target="app/src/main/AndroidManifest.xml"
to simply target="AndroidManifest.xml"
, otherwise it kept creating an empty queries
tag in the AndroidManifest.xml
for me.
The plugin also stopped crashing, so it's working as expected, thank you 👍
Anyone has more feedback with the PR #368?
Does it work stably on Android 11, with Chinese smartphones (Xiaomi, for example)?
Do the attachments work OK? Does it pop up only email Apps?
@PetePrattis @ebhsgit @maxzirilli @niclaforge Which PR are you using in your projects in production?
It's almost a pair of days that application crash when we try to open client.
Function HasClient also returns false; GMail is correctly installed;
We have Xiami phones and Android 11 installed