question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to add an attachment from getApplicationDocumentsDirectory()

See original GitHub issue

When 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:closed
  • Created 5 years ago
  • Reactions:6
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
skaletaPLcommented, Nov 2, 2019

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().

4reactions
MahMooscommented, Feb 21, 2019

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/

Read more comments on GitHub >

github_iconTop Results From Across the Web

dart - Cannot find the path provided by ... - Stack Overflow
If you're using a file explorer app installed on the device, ... that your file is not stored in getApplicationDocumentsDirectory() .
Read more >
Unable to load File from applicationDocumentDirectory in Flutter
Assets are part of the application bundle and not files in the document folder. You cannot use getApplicationDocumentsDirectory and then later ...
Read more >
Can't Add Attachments with Long File Names Using Windows
Symptoms. When adding an attachment by clicking 'Attachments', then 'Browse', navigating to a file and then clicking 'Open', the file path ...
Read more >
Read and write files | Semantic portal — learn smart!
Once you know where to store the file, create a reference to the file's full ... getApplicationDocumentsDirectory(); return directory.path; } Future<File> ...
Read more >
path_provider | Flutter Package - Pub.dev
To use this plugin, add path_provider as a dependency in your pubspec.yaml file. Example #. Directory tempDir = await getTemporaryDirectory(); String tempPath = ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found