New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Attachments not working: java.lang.ClassCastException: android.text.SpannableStringBuilder cannot be cast to java.util.ArrayList #46
Comments
can you provide more context? that error message is unfortunately the same as with #13 / cordova-plugin-email although annoying has been there since forever and does not crash the app. |
So basically, when calling FlutterMailer with link to attachment it fails. The email body will be empty and no attachment after I push though.
final MailOptions mailOptions = MailOptions(
body: body,
subject: subject,
recipients: [scoutReport.sendTo],
isHTML: true,
bccRecipients: [],
ccRecipients: [],
attachments: [
pdfFile.path,
],
);
// open emailer
FlutterMailer.send(mailOptions).then((_) {});
I narrowed it down to the first setting of intent:
I/flutter (17760): Using local cached file:/data/user/0/com.pestscope.pestscopemobile/app_flutter/Reports/-94741-1-11.pdf
I/flutter (17760): /data/user/0/com.pestscope.pestscopemobile/cache-94741-1-11.pdf
W/Bundle (17760): Key android.intent.extra.TEXT expected ArrayList<CharSequence> but value was a android.text.SpannableStringBuilder. The default value <null> was returned.
W/Bundle (17760): Attempt to cast generated internal exception:
W/Bundle (17760): java.lang.ClassCastException: android.text.SpannableStringBuilder cannot be cast to java.util.ArrayList
W/Bundle (17760): at android.os.BaseBundle.getCharSequenceArrayList(BaseBundle.java:1343)
W/Bundle (17760): at android.os.Bundle.getCharSequenceArrayList(Bundle.java:1145)
W/Bundle (17760): at android.content.Intent.getCharSequenceArrayListExtra(Intent.java:9005)
W/Bundle (17760): at android.content.Intent.migrateExtraStreamToClipData(Intent.java:12041)
W/Bundle (17760): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1721)
W/Bundle (17760): at android.app.Activity.startActivityForResult(Activity.java:5377)
W/Bundle (17760): at android.app.Activity.startActivityForResult(Activity.java:5335)
W/Bundle (17760): at com.dataxad.flutter_mailer.MethodCallHandlerImpl.onMethodCall(MethodCallHandlerImpl.java:73)
W/Bundle (17760): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
W/Bundle (17760): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:84)
W/Bundle (17760): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:865)
W/Bundle (17760): at android.os.MessageQueue.nativePollOnce(Native Method)
W/Bundle (17760): at android.os.MessageQueue.next(MessageQueue.java:335)
W/Bundle (17760): at android.os.Looper.loop(Looper.java:206)
W/Bundle (17760): at android.app.ActivityThread.main(ActivityThread.java:8595)
W/Bundle (17760): at java.lang.reflect.Method.invoke(Native Method)
W/Bundle (17760): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
W/Bundle (17760): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
|
So it does not crash app but makes FlutterMailer unusable to send attachments. In the links I provided there are some workarounds proposed. |
I am seeing this issue and the workarounds are Java-specific. The issue is appearing on the newest versions of Android as well. |
any solution?? |
Sending attachments broke recently:
traced error to Android 4 bug:
https://stackoverflow.com/questions/15776416/java-lang-classcastexception-android-text-spannablestringbuilder-cannot-be-cast
The text was updated successfully, but these errors were encountered: