Home > Software engineering >  Flutter_downloader download keep failing
Flutter_downloader download keep failing

Time:07-07

Flutter_downloader is not downloading my file, this is the log when i run the code ::

DownloadWorker [url='https://tooxclusive.com/wp-content/uploads/2022/03/Asake-Sungba.mp3',filename=null,savedDir=/storage/emulated/0/Download,header=,isResume=false,status=1
D/DownloadWorker(25194): Update notification: [notificationId: 1, title: 'https://tooxclusive.com/wp-content/uploads/2022/03/Asake-Sungba.mp3', status: 2, progress: 0]
D/DownloadWorker(25194): Update too frequently!!!!, but it is the final update, we should sleep a second to ensure the update call can be processed
D/DownloadWorker(25194): Update notification: 
[notificationId: 1, title: 'https://tooxclusive.com/wp-content/uploads/2022/03/Asake-Sungba.mp3', status: 4, progress: -1]
W/System.err(25194): java.net.MalformedURLException: no protocol: 'https://tooxclusive.com/wp-content/uploads/2022/03/Asake-Sungba.mp3'
W/System.err(25194):    at java.net.URL.<init>(URL.java:590)
W/System.err(25194):    at java.net.URL.<init>(URL.java:487)
W/System.err(25194):    at java.net.URL.<init>(URL.java:436)
W/System.err(25194):    at vn.hunghd.flutterdownloader.DownloadWorker.downloadFile(DownloadWorker.java:305)
W/System.err(25194):    at vn.hunghd.flutterdownloader.DownloadWorker.doWork(DownloadWorker.java:235)
W/System.err(25194):    at androidx.work.Worker$1.run(Worker.java:86)
W/System.err(25194):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
W/System.err(25194):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
W/System.err(25194):    at java.lang.Thread.run(Thread.java:764)
I/WM-WorkerWrapper(25194): Worker result SUCCESS for Work [ id=52272908-105d-442c-a326-708c65c9a276, tags=
[ flutter_download_task, vn.hunghd.flutterdownloader.DownloadWorker ] ]

And this is the code ::

await FlutterDownloader.enqueue(
    url: _url, //url is https://tooxclusive.com/wp-content/uploads/2022/03/Asake-Sungba.mp3
    savedDir: '/storage/emulated/0/Download',
    showNotification: true,
    saveInPublicStorage: true
);

CodePudding user response:

The worker shows success. Please add internet, read and write permission in manifest since you are accessing the download folder

    <uses-permission android:name="android.permission.INTERNET"/> 
  
     <!-- Permissions options for the `storage` group --> 
     <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> 
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

CodePudding user response:

do one thing. Add two lines under void main()

 await FlutterDownloader.initialize(
      debug: true // optional: set false to disable printing logs to console
      );

  FlutterDownloader.registerCallback(DownloadClass.callback);

make DownloadClass as a Top-Level Function, Like Mentioned in the picture below.

enter image description here

Hope that will resolve your problem.

Thanks

  • Related