IllegalArgumentException from ItentUtils.buildIntent in downloadFile method
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
I facing the same bug here.
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
Below soln resolve issue.
You have to add xml/provider_paths.xml in android res folder