fix false “no email Managers available” on Android 11+ (SENDTO without attachments)#67
fix false “no email Managers available” on Android 11+ (SENDTO without attachments)#67taljacobson wants to merge 3 commits intomasterfrom
Conversation
…ttachment SENDTO) - Symptom: Fresh install, send mail with subject/body and no attachment shows “no email Managers available” (Pixel 8 Pro / Android 16). Works with attachments. Choosing “Always” for a mail app masks the issue; “Only once” keeps failing. - Root cause: Pre-querying PackageManager for ACTION_SENDTO (mailto:) is blocked by Android 11+ package visibility unless declared in <queries> or a default app exists, so queries return empty even when handlers are available. With attachments, ACTION_SEND remains discoverable. - Fix: Remove PackageManager pre-query/resolve for SENDTO and start the implicit intent directly (startActivityForResult), catching ActivityNotFoundException to report real absence only. Preserves chooser UX and default behavior (“Only once”/“Always”). Keep appSchema via setPackage and attachment flow with FLAG_GRANT_READ_URI_PERMISSION unchanged.
…and example migration
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a false "no email Managers available" error on Android 11+ when sending emails without attachments. The issue was caused by package visibility restrictions that made PackageManager queries return empty results unless specific queries were declared in the manifest.
- Removes PackageManager pre-query for ACTION_SENDTO intent and launches intent directly
- Migrates example Android build to Flutter's declarative Gradle plugins
- Updates Android compileSdk to 36 and migrates to embedding v2
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pubspec.yaml | Bumps version to 3.0.2 for the Android fix |
| example/android/settings.gradle | Migrates to declarative Gradle plugin management |
| example/android/build.gradle | Removes buildscript block in favor of declarative plugins |
| example/android/app/src/main/java/com/dataxad/flutter_mailer_example/EmbeddingV1Activity.java | Updates import to use embedding v2 FlutterActivity |
| example/android/app/build.gradle | Migrates to declarative plugins and updates compileSdk to 36 |
| android/src/main/java/com/dataxad/flutter_mailer/MethodCallHandlerImpl.java | Fixes Android 11+ email sending by removing PackageManager pre-query |
| CHANGELOG.md | Documents the Android fix and example migration changes |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| } catch (ActivityNotFoundException e) { | ||
| result.error("not_available", "no email Managers available", null); | ||
| mResult = null; | ||
| } |
There was a problem hiding this comment.
[nitpick] The variable mResult is being set to null in the catch block, but it's also set to null in the existing catch block for FlutterMailerException below. Consider extracting this cleanup into a helper method to avoid duplication.
Android: fix false “no email Managers available” on Android 11+ (SENDTO without attachments)
Summary
Reproduction
send()with subject/body and no attachments.Root cause
ACTION_SENDTO (mailto:). On Android 11+, package visibility restrictions often make this query return empty unless the host app declares<queries>.Changes
ACTION_SENDTO.startActivityForResultand only report an error ifActivityNotFoundExceptionis thrown.appSchemaviaintent.setPackage(...)when provided.FLAG_GRANT_READ_URI_PERMISSION.Behavior
Compatibility
<queries>required for this flow (optional forisAppInstalled).Testing
Example project updates
dev.flutter.flutter-plugin-loader/dev.flutter.flutter-gradle-plugin).compileSdkto 36.Related issues
Changelog