Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Download is Not Working #953

Open
techievichaar opened this issue May 12, 2024 · 3 comments
Open

Download is Not Working #953

techievichaar opened this issue May 12, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@techievichaar
Copy link

I'm getting this error

D/EGL_emulation( 2988): app_time_stats: avg=788.55ms min=4.57ms max=20855.36ms count=27

I/flutter ( 2988): Saved Directory: /storage/emulated/0/Android/data/com.example.pixifusion/files/downloads

I/flutter ( 2988): Download Task ID: f30f65e2-ab58-4e67-bd40-570efefad7e0

W/System.err( 2988): java.lang.NullPointerException

W/System.err( 2988): at vn.hunghd.flutterdownloader.DownloadWorker.downloadFile(DownloadWorker.kt:393)

W/System.err( 2988): at vn.hunghd.flutterdownloader.DownloadWorker.doWork(DownloadWorker.kt:206)

W/System.err( 2988): at androidx.work.Worker$1.run(Worker.java:86)

W/System.err( 2988): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)

W/System.err( 2988): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)

W/System.err( 2988): at java.lang.Thread.run(Thread.java:1012)

I/WM-WorkerWrapper( 2988): Worker result FAILURE for Work [ id=f30f65e2-ab58-4e67-bd40-570efefad7e0, tags={ flutter_download_task, vn.hunghd.flutterdownloader.DownloadWorker } ]

@techievichaar techievichaar added the bug Something isn't working label May 12, 2024
@adminant
Copy link

adminant commented May 17, 2024

Same issue, it seems that in this code (DownloadWorker.kt)

                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && saveInPublicStorage) {
                    val uri = createFileInPublicDownloadsDir(actualFilename, contentType)
                    savedFilePath = getMediaStoreEntryPathApi29(uri!!)
                    outputStream = context.contentResolver.openOutputStream(uri, "w")
                } else {
                    val file = createFileInAppSpecificDir(actualFilename!!, savedDir)
                    savedFilePath = file!!.path
                    outputStream = FileOutputStream(file, false)
                }

uri or file var is null (depend on which Android version we have)

@ZRShamim
Copy link

Did someone solved this issue? any fix?

@SteelTitan247
Copy link

You can add a try catch block here. I added it and my issue was resolved. In my case, a file with same name was already present on the location of my downloading file, and that's why it was failing. By adding a try catch, at least the code will not break.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants