taljacobson / flutter_mailer

A wrapper on top of MFMailComposeViewController from iOS and Mail Intent on android
MIT License
47 stars 39 forks source link

Flutter mailer issue in android #25

Closed 0xdhu closed 4 years ago

0xdhu commented 4 years ago

Hello. I wanted to send email to other person in flutter so I was using flutter_mailer package for this. I was thinking code has no issue but when I try to send email. i had issue like this. please help me.

E/Flutter_mailer Size==1( 4356): Attempt to invoke virtual method 'void android.app.Activity.startActivityForResult(android.content.Intent, int)' on a null object reference
E/flutter ( 4356): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(error, Attempt to invoke virtual method 'void android.app.Activity.startActivityForResult(android.content.Intent, int)' on a null object reference, null)
E/flutter ( 4356): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569:7)
E/flutter ( 4356): #1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:321:33)
E/flutter ( 4356): <asynchronous suspension>
E/flutter ( 4356): #2      FlutterMailer.send (package:flutter_mailer/flutter_mailer.dart:9:21)
E/flutter ( 4356): #3      MailService.sendMailToClient (package:billsender/service/mailservice.dart:16:25)

This is my flutter doctor -v

Flutter (Channel dev, v1.16.4-pre.132, on Mac OS X 10.15.4 19E287, locale
    en-CN)
    • Flutter version 1.16.4-pre.132 at /Users/kk/Developer/flutter
    • Framework revision 727552e5ca (4 weeks ago), 2020-04-06 13:38:41 -0700
    • Engine revision e1e6ced81d
    • Dart version 2.7.0

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    • Android SDK at /Users/kk/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling
      support)
    • Platform android-29, build-tools 29.0.3
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      1.8.0_202-release-1483-b49-5587405)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.0)
    • Xcode at /Users/kk/Downloads/Xcode.app/Contents/Developer
    • Xcode 11.0, Build version 11A420a
    • CocoaPods version 1.9.1

[✓] Android Studio (version 3.5)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 44.0.1
    • Dart plugin version 191.8593
    • Java version OpenJDK Runtime Environment (build
      1.8.0_202-release-1483-b49-5587405)

[!] IntelliJ IDEA Ultimate Edition (version 2020.1)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    • For information about installing plugins, see
      https://flutter.dev/intellij-setup/#installing-the-plugins

[✓] VS Code (version 1.44.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.10.1

[✓] Connected device (1 available)

This is my script

import 'package:flutter_mailer/flutter_mailer.dart';

class MailService {

  void sendMailToClient(String path) async{
    final MailOptions mailOptions = MailOptions(
      body: 'The new Folder with some bills arrived.',
      subject: 'From Bills App',
      recipients: ['myemail@163.com'],
      isHTML: true,
      bccRecipients: ['other@example.com'],
      ccRecipients: ['third@example.com'],
//    attachments: [ 'path/to/image.png', ],
    );
    await FlutterMailer.send(mailOptions);
  }
}
taljacobson commented 4 years ago

Probably related to #19.

Do you mind trying out 0.5.0-dev.7.

taljacobson commented 4 years ago

do you still experience this issue with 0.5.0 and flutter 1.17.0.

did you upgrade your android project based off Upgrading-pre-1.12-Android-projects?