Unable to add an attachment from getApplicationDocumentsDirectory()
See original GitHub issueWhen I add a file in the attachment from getExternalStorageDirectory(), it works fine. But it gives an error or says cannot attach attachment when I use getApplicationDocumentsDirectory() or getTemporaryDirectory(). I get the following error:
E/MethodChannel#flutter_email_sender(20680): Failed to handle method call E/MethodChannel#flutter_email_sender(20680): java.lang.IllegalArgumentException: Failed to find configured root that contains /data/data/com.example.clbrapp/app_flutter/Technical_Report.pdf E/MethodChannel#flutter_email_sender(20680): at android.support.v4.content.FileProvider$SimplePathStrategy.getUriForFile(FileProvider.java:739) E/MethodChannel#flutter_email_sender(20680): at android.support.v4.content.FileProvider.getUriForFile(FileProvider.java:418) E/MethodChannel#flutter_email_sender(20680): at com.sidlatau.flutteremailsender.FlutterEmailSenderPlugin.sendEmail(FlutterEmailSenderPlugin.kt:85) E/MethodChannel#flutter_email_sender(20680): at com.sidlatau.flutteremailsender.FlutterEmailSenderPlugin.onMethodCall(FlutterEmailSenderPlugin.kt:30) E/MethodChannel#flutter_email_sender(20680): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:191) E/MethodChannel#flutter_email_sender(20680): at io.flutter.view.FlutterNativeView.handlePlatformMessage(FlutterNativeView.java:163) E/MethodChannel#flutter_email_sender(20680): at android.os.MessageQueue.nativePollOnce(Native Method) E/MethodChannel#flutter_email_sender(20680): at android.os.MessageQueue.next(MessageQueue.java:326) E/MethodChannel#flutter_email_sender(20680): at android.os.Looper.loop(Looper.java:160) E/MethodChannel#flutter_email_sender(20680): at android.app.ActivityThread.main(ActivityThread.java:6669) E/MethodChannel#flutter_email_sender(20680): at java.lang.reflect.Method.invoke(Native Method) E/MethodChannel#flutter_email_sender(20680): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) E/MethodChannel#flutter_email_sender(20680): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Please solve this, because getExternalStorageDirectory() does not work in IOS.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:6
- Comments:11 (2 by maintainers)
I’m using path_provider plugin and it doesn’t work with getApplicationDocumentsDirectory(). I’m ussing version flutter_email_sender: 2.1.0 Exception: E/MethodChannel#flutter_email_sender(18995): Failed to handle method call E/MethodChannel#flutter_email_sender(18995): java.lang.IllegalArgumentException: Failed to find configured root that contains /data/data/pl.kzpert.kzpert_flutter/app_flutter/Karty zgłoszeniowe PERT/adam-2019-11-02 09-50-34.pdf E/MethodChannel#flutter_email_sender(18995): at androidx.core.content.FileProvider$SimplePathStrategy.getUriForFile(FileProvider.java:739) E/MethodChannel#flutter_email_sender(18995): at androidx.core.content.FileProvider.getUriForFile(FileProvider.java:418) E/MethodChannel#flutter_email_sender(18995): at com.sidlatau.flutteremailsender.FlutterEmailSenderPlugin.sendEmail(FlutterEmailSenderPlugin.kt:108) E/MethodChannel#flutter_email_sender(18995): at com.sidlatau.flutteremailsender.FlutterEmailSenderPlugin.onMethodCall(FlutterEmailSenderPlugin.kt:41) E/MethodChannel#flutter_email_sender(18995): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:222) E/MethodChannel#flutter_email_sender(18995): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:96) E/MethodChannel#flutter_email_sender(18995): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:656) E/MethodChannel#flutter_email_sender(18995): at android.os.MessageQueue.nativePollOnce(Native Method) E/MethodChannel#flutter_email_sender(18995): at android.os.MessageQueue.next(MessageQueue.java:326) E/MethodChannel#flutter_email_sender(18995): at android.os.Looper.loop(Looper.java:160) E/MethodChannel#flutter_email_sender(18995): at android.app.ActivityThread.main(ActivityThread.java:6669) E/MethodChannel#flutter_email_sender(18995): at java.lang.reflect.Method.invoke(Native Method) E/MethodChannel#flutter_email_sender(18995): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) E/MethodChannel#flutter_email_sender(18995): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
It works with getTemporaryDirectory().
I have the same issue here. I couldn’t figure out why it’s looking in
/data/data/com.example.clbrapp/
while the path I’m providing starts with/data/user/0/com.example.clbrapp/