flutter_downloader icon indicating copy to clipboard operation
flutter_downloader copied to clipboard

IllegalArgumentException from ItentUtils.buildIntent in downloadFile method

Open claptv opened this issue 2 years ago • 4 comments

The getApplicationDocumentsDirectory method is returning a path formatted as **/data/user/0**/com.example.app/app_flutter, which is causing a failure in a plugin that expects a path in the format of **/data/data/**com.example.app/app_flutter.

I created Download directory under /data/user/0**/com.example.app/app_flutter

D/DownloadWorker(10806): Update notification: {notificationId: 22, title: image.jpg, status: FAILED, progress: -1} W/System.err(10806): java.lang.IllegalArgumentException: Failed to find configured root that contains /data/data/com.example.app/app_flutter/Download/image.jpg W/System.err(10806): at androidx.core.content.FileProvider$SimplePathStrategy.getUriForFile(FileProvider.java:825) W/System.err(10806): at androidx.core.content.FileProvider.getUriForFile(FileProvider.java:450) W/System.err(10806): at vn.hunghd.flutterdownloader.IntentUtils.buildIntent(IntentUtils.kt:19) W/System.err(10806): at vn.hunghd.flutterdownloader.IntentUtils.validatedFileIntent(IntentUtils.kt:36) W/System.err(10806): at vn.hunghd.flutterdownloader.DownloadWorker.downloadFile(DownloadWorker.kt:446) W/System.err(10806): at vn.hunghd.flutterdownloader.DownloadWorker.doWork(DownloadWorker.kt:206) W/System.err(10806): at androidx.work.Worker$1.run(Worker.java:86) W/System.err(10806): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137) W/System.err(10806): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637) W/System.err(10806): at java.lang.Thread.run(Thread.java:1012)

** UPDATE ** I learned that '/data/user/0' is a symlink to '/data/data' directory. Changed the bug title to "IllegalArgumentException from ItentUtils.buildIntent in downloadFile method."

Expected behavior

Downloads must be completed successfully, and files should be correctly saved in the **/data/user/0**/com.example.app/app_flutter/Download directory without any errors.

Device information:

  • Device: Emulator (Pixel 7 Pro API 33)
  • OS: Android 13
  • plugin version 1.11.5

claptv avatar Nov 29 '23 21:11 claptv

I facing the same bug here.

vzhilong avatar Nov 30 '23 11:11 vzhilong

Same problem with a temporary directory.

Update notification: {notificationId: 66, title: 20231129_040121_696.jpg, status: FAILED, progress: -1} W/System.err(17793): java.lang.IllegalArgumentException: Failed to find configured root that contains /data/data/com.example.app/cache/image.jpg

claptv avatar Dec 03 '23 03:12 claptv

Below soln resolve issue.

You have to add xml/provider_paths.xml in android res folder

Screenshot 2024-05-20 at 3 23 47 PM

yogendra-algoworks avatar May 20 '24 09:05 yogendra-algoworks