fluttercommunity / flutter_downloader

Flutter Downloader - A plugin for creating and managing download tasks.
https://pub.dev/packages/flutter_downloader
BSD 3-Clause "New" or "Revised" License
915 stars 515 forks source link

--- Failed to create image decoder with message 'unimplemented' #113

Closed weiliang0626 closed 5 years ago

weiliang0626 commented 5 years ago

when i perform FlutterDownloader.loadTasks(),it reported Failed to create image decoder with message 'unimplemented',

this is my code :

Future get _apkLocalPath async { final directory = await getExternalStorageDirectory(); return directory.path; }

Future _executeDownload(String downLoadUrl) async { final path = await _apkLocalPath; final taskId = await FlutterDownloader.enqueue( url: downLoadUrl, fileName: 'update.apk', savedDir: path, showNotification: true, openFileFromNotification: true ); FlutterDownloader.registerCallback((id, status, progress) { if (taskId == id && status == DownloadTaskStatus.complete) { print('install'); _installApk(); } });

await FlutterDownloader.loadTasks(); }

[✓] Flutter (Channel stable, v1.7.8+hotfix.3, on Mac OS X 10.13.6 17G7024, locale zh-Hans-CN)

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3) [✓] Xcode - develop for iOS and macOS (Xcode 10.1) [✓] iOS tools - develop for iOS devices [✓] Android Studio (version 3.3) [✓] VS Code (version 1.37.1) [✓] Connected device (1 available)

nnnam2298 commented 5 years ago

same issue when download image

zxj17815 commented 5 years ago

I had the same problem

saviourdog commented 5 years ago

same problem

hnvn commented 5 years ago

Does it happen on the example project?

aliyazdi75 commented 5 years ago

Does it happen on the example project?

@hnvn yes, it does. I have tested on android 10 and images and audio files have been downloaded but video files .mp4 downloaded till 100% but they it can't save them on phone. I did all these stuffs on this issue #119 but doesn't work for me with this error: I/flutter (27855): Download task (fede27cf-1e24-4fea-bab7-4b1206aee2f4) is in status (DownloadTaskStatus(2)) and process (100) D/skia (27855): --- Failed to create image decoder with message 'unimplemented' I/flutter (27855): Download task (fede27cf-1e24-4fea-bab7-4b1206aee2f4) is in status (DownloadTaskStatus(4)) and process (-1) W/System.err(27855): java.lang.IllegalArgumentException: MIME type video/mp4 cannot be inserted into content://media/external/images/media; expected MIME type under image/* W/System.err(27855): at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:170) W/System.err(27855): at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:140) W/System.err(27855): at android.content.ContentProviderProxy.insert(ContentProviderNative.java:481) W/System.err(27855): at android.content.ContentResolver.insert(ContentResolver.java:1828) W/System.err(27855): at vn.hunghd.flutterdownloader.DownloadWorker.addImageOrVideoToGallery(DownloadWorker.java:471) W/System.err(27855): at vn.hunghd.flutterdownloader.DownloadWorker.downloadFile(DownloadWorker.java:282) W/System.err(27855): at vn.hunghd.flutterdownloader.DownloadWorker.doWork(DownloadWorker.java:115) W/System.err(27855): at androidx.work.Worker$1.run(Worker.java:85) W/System.err(27855): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) W/System.err(27855): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) W/System.err(27855): at java.lang.Thread.run(Thread.java:919) I/WM-WorkerWrapper(27855): Worker result FAILURE for Work [ id=fede27cf-1e24-4fea-bab7-4b1206aee2f4, tags={ flutter_download_task, vn.hunghd.flutterdownloader.DownloadWorker } ]

hnvn commented 5 years ago

OK, It seems to be a problem with Android Q. I will have a look at it

hnvn commented 5 years ago

It turns out that our problem comes from changes in Flutter platform channel to support background execution. I need to update the plugin to follow new changes.

aliyazdi75 commented 5 years ago

What are these changes?

hnvn commented 5 years ago

https://medium.com/flutter/executing-dart-in-the-background-with-flutter-plugins-and-geofencing-2b3e40a1a124

mrdong916 commented 5 years ago

I have the same problem. Is there an interim solution?

D/DownloadWorker(10661): DownloadWorker{url=xxxxx,filename=主题曲.mp3,savedDir=/storage/emulated/0/songs/,header=,isResume=false
D/skia    (10661): --- Failed to create image decoder with message 'unimplemented'
D/DownloadWorker(10661): Open connection to xxxxxxxxx
D/NetworkSecurityConfig(10661): No Network Security Config specified, using platform default
D/DownloadWorker(10661): Response with redirection code
D/DownloadWorker(10661): Location = xxxxxx
D/DownloadWorker(10661): New url: xxxxx
D/DownloadWorker(10661): Open connection to xxxxxx
D/DownloadWorker(10661): Content-Type = audio/mpeg
D/DownloadWorker(10661): Content-Length = 7907551
D/DownloadWorker(10661): Charset = null
D/DownloadWorker(10661): fileName = 主题曲.mp3
D/skia    (10661): --- Failed to create image decoder with message 'unimplemented'
D/skia    (10661): --- Failed to create image decoder with message 'unimplemented'
D/skia    (10661): --- Failed to create image decoder with message 'unimplemented'
D/skia    (10661): --- Failed to create image decoder with message 'unimplemented'
D/skia    (10661): --- Failed to create image decoder with message 'unimplemented'
D/skia    (10661): --- Failed to create image decoder with message 'unimplemented'
D/skia    (10661): --- Failed to create image decoder with message 'unimplemented'
D/skia    (10661): --- Failed to create image decoder with message 'unimplemented'
D/skia    (10661): --- Failed to create image decoder with message 'unimplemented'
D/skia    (10661): --- Failed to create image decoder with message 'unimplemented'
D/skia    (10661): --- Failed to create image decoder with message 'unimplemented'
W/System.err(10661): java.lang.IllegalArgumentException: Couldn't find meta-data for provider with authority tk.musichub.music_hub.flutter_downloader.provider
W/System.err(10661):    at androidx.core.content.FileProvider.parsePathStrategy(FileProvider.java:606)
W/System.err(10661):    at androidx.core.content.FileProvider.getPathStrategy(FileProvider.java:579)
W/System.err(10661):    at androidx.core.content.FileProvider.getUriForFile(FileProvider.java:417)
W/System.err(10661):    at vn.hunghd.flutterdownloader.IntentUtils.buildIntent(IntentUtils.java:23)
W/System.err(10661):    at vn.hunghd.flutterdownloader.IntentUtils.validatedFileIntent(IntentUtils.java:35)
W/System.err(10661):    at vn.hunghd.flutterdownloader.DownloadWorker.downloadFile(DownloadWorker.java:286)
W/System.err(10661):    at vn.hunghd.flutterdownloader.DownloadWorker.doWork(DownloadWorker.java:115)
W/System.err(10661):    at androidx.work.Worker$1.run(Worker.java:85)
W/System.err(10661):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
W/System.err(10661):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
W/System.err(10661):    at java.lang.Thread.run(Thread.java:764)
I/WM-WorkerWrapper(10661): Worker result FAILURE for Work [ id=689e7d7c-9bef-4629-bf7d-7a6eab11f6b9, tags={ flutter_download_task, vn.hunghd.flutterdownloader.DownloadWorker } ]
hnvn commented 5 years ago

I am working on it, you can try the latest code in refactor branch, it's not complete but it is working in Android, I need more time to implement in iOS.

mrdong916 commented 5 years ago

I am working on it, you can try the latest code in refactor branch, it's not complete but it is working in Android, I need more time to implement in iOS.

I am using this branch and I have a very strange problem.

FlutterDownloader.registerCallback(
      (id, status, progress) {
        _queryStartAll().then((data) {
          setState(() {
            _dms = data;
          });
        });

        int index = _dms.indexWhere((dm) => dm.taskId == id);
        DownloadModel dm = _dms[index];
        dm.progress = progress;
        dm.status = status.value;
        setState(
          () {
            _dms[index] = dm;
          },
        );
      },
    );
════════ (2) Exception caught by widgets library ═══════════════════════════════════════════════════
callback must be a top-level or a static function
'package:flutter_downloader/src/downloader.dart':
Failed assertion: line 360 pos 12: 'callbackHandle != null'
hnvn commented 5 years ago

It's expected, callback is re-implemented by using background isolate and it must be a static or top-level function now, you can look at example codes to have more detail

hnvn commented 5 years ago

v1.3.0 has landed. I believe this issue should be fixed

aliyazdi75 commented 5 years ago

Thanks for your update, can you please tell me what happened in this update and why FlutterApplication.java is needed and isn't it bad to replace android:name="io.flutter.app.FlutterApplication" vs android:name=".MyApplication"?

hnvn commented 5 years ago

Have a look at this codes: https://github.com/fluttercommunity/flutter_downloader/blob/master/android/src/main/java/vn/hunghd/flutterdownloader/DownloadWorker.java#L108

oliverbytes commented 5 years ago

@hnvn Super Thanks!!!! can you also do an example MyApplication.java for kotlin please?

mrdong916 commented 5 years ago

@hnvn Super Thanks!!!! can you also do an example MyApplication.java for kotlin please?


internal class MusicApplication : FlutterApplication(), PluginRegistry.PluginRegistrantCallback {
    override fun registerWith(registry: PluginRegistry) {
        GeneratedPluginRegistrant.registerWith(registry)
    }
}
mrdong916 commented 5 years ago

This phenomenon will still occur after the update, and the download callback is also a failure.

I/Toast   (17579): Show toast from OpPackageName:xyz.a5in.music_5in, PackageName:xyz.a5in.music_5in
W/WM-WorkSpec(17579): Backoff delay duration less than minimum value
I/flutter (17579): Download task is enqueued with id(527acce0-f9dd-415a-849b-a07fedc7e544)
E/DownloadWorker(17579): Fatal: failed to find callback
D/DownloadWorker(17579): DownloadWorker{url=http://mobileoc.music.tc.qq.com/F000002dmSnc4e8wTm.flac?guid=lnbgb&vkey=0423811E4300FEF7BF982672D4C3AD0E23CFA6EF7BB77035D6D1AD76E7505FB9A965D7DD3EDA3437A0EF9BA0403ABEEBB0841A742F494BC4&uin=0&fromtag=8,filename=你好-殷文艺-Y.flac,savedDir=/storage/emulated/0/五音/songs,header=,isResume=false
D/skia    (17579): --- Failed to create image decoder with message 'unimplemented'
D/DownloadWorker(17579): Open connection to http://mobileoc.music.tc.qq.com/F000002dmSnc4e8wTm.flac?guid=lnbgb&vkey=0423811E4300FEF7BF982672D4C3AD0E23CFA6EF7BB77035D6D1AD76E7505FB9A965D7DD3EDA3437A0EF9BA0403ABEEBB0841A742F494BC4&uin=0&fromtag=8
D/DownloadWorker(17579): Content-Type = audio/flac
D/DownloadWorker(17579): Content-Length = 21010915
D/DownloadWorker(17579): Charset = null
D/DownloadWorker(17579): fileName = 你好-殷文艺-Y.flac
D/skia    (17579): --- Failed to create image decoder with message 'unimplemented'
D/skia    (17579): --- Failed to create image decoder with message 'unimplemented'
D/skia    (17579): --- Failed to create image decoder with message 'unimplemented'
D/skia    (17579): --- Failed to create image decoder with message 'unimplemented'
D/skia    (17579): --- Failed to create image decoder with message 'unimplemented'
D/skia    (17579): --- Failed to create image decoder with message 'unimplemented'
D/skia    (17579): --- Failed to create image decoder with message 'unimplemented'
D/skia    (17579): --- Failed to create image decoder with message 'unimplemented'
D/skia    (17579): --- Failed to create image decoder with message 'unimplemented'
D/skia    (17579): --- Failed to create image decoder with message 'unimplemented'
D/DownloadWorker(17579): Setting an intent to open the file /storage/emulated/0/五音/songs/你好-殷文艺-Y.flac
D/skia    (17579): --- Failed to create image decoder with message 'unimplemented'
D/DownloadWorker(17579): File downloaded
I/WM-WorkerWrapper(17579): Worker result SUCCESS for Work [ id=527acce0-f9dd-415a-849b-a07fedc7e544, tags={ flutter_download_task, vn.hunghd.flutterdownloader.DownloadWorker } ]
oliverbytes commented 5 years ago

@hnvn Super Thanks!!!! can you also do an example MyApplication.java for kotlin please?


internal class MusicApplication : FlutterApplication(), PluginRegistry.PluginRegistrantCallback {
    override fun registerWith(registry: PluginRegistry) {
        GeneratedPluginRegistrant.registerWith(registry)
    }
}

thanks a lot. but I guess you discovered another failure so I might just wait for the next release again.

braysonjohn148 commented 5 years ago

Am getting this error then my App crushes (just updated to 1.3.1)... is there anything i can do or i wait for the next release. Thank you.

W/WM-WorkSpec(18893): Backoff delay duration less than minimum value I/flutter (18893): Download task is enqueued with id(some id here) D/AndroidRuntime(18893): Shutting down VM E/AndroidRuntime(18893): FATAL EXCEPTION: main java.lang.AssertionError: The Application must be implemented PluginRegistrantCallback E/AndroidRuntime(18893): at vn.hunghd.flutterdownloader.DownloadWorker.startBackgroundIsolate(DownloadWorker.java:106) E/AndroidRuntime(18893): at vn.hunghd.flutterdownloader.DownloadWorker.access$000(DownloadWorker.java:59) E/AndroidRuntime(18893): at vn.hunghd.flutterdownloader.DownloadWorker$1.run(DownloadWorker.java:97) E/AndroidRuntime(18893): at android.os.Handler.handleCallback(Handler.java:873) E/AndroidRuntime(18893): at android.os.Handler.dispatchMessage(Handler.java:99) E/AndroidRuntime(18893): at android.os.Looper.loop(Looper.java:193) E/AndroidRuntime(18893): at android.app.ActivityThread.main(ActivityThread.java:6825) E/AndroidRuntime(18893): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime(18893): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:497) E/AndroidRuntime(18893): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

hnvn commented 5 years ago

It's not bug, it's expected when you are missing a required configuration. See README for more detail

braysonjohn148 commented 5 years ago

It's not bug, it's expected when you are missing a required configuration. See README for more detail

do you mean i change <application android:name="io.flutter.app.FlutterApplication".....

to

<application android:name=".io.flutter.app.FlutterApplication"

Sorry am new to this..?

braysonjohn148 commented 5 years ago

Sir, please create a video tutorial or a sample code for this, i tried for 3 days still getting error. Please.

roychenggit commented 5 years ago

its happed again for v1.3.3,my phone version is huawei android 9.0,

jiyangjjj commented 5 years ago

I also have this error in v1.3.3……Does somebody help?

johnny-stevie commented 5 years ago

@roychenggit @jiyangjjj This is what you are supposed to do <application android:name=".MyApplication"...>

roychenggit commented 5 years ago

i am sure , my setting is ok-------- 原始邮件 --------发件人: johnny-stevie notifications@github.com日期: 2019年11月16日周六 07:16收件人: fluttercommunity/flutter_downloader flutter_downloader@noreply.github.com抄送: roychenggit stillat@qq.com, Mention mention@noreply.github.com主 题: Re: [fluttercommunity/flutter_downloader] --- Failed to create image decoder with message 'unimplemented' (#113)@roychenggit @jiyangjjj This is what you are supposed to do <application android:name=".MyApplication"...>

—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or unsubscribe.

hnvn commented 5 years ago

The logs ---Failed to create image decoder with message 'unimplemented' is not much concerned. It's a debug message from Skia engine, I have no idea about it but the application still works well with it, you can verify in the example project

johnny-stevie commented 4 years ago

I get the error: W/System.err( 8810): java.lang.SecurityException: Permission Denial: writing com.android.providers.media.MediaProvider uri content://media/external/images/media from pid=8810, uid=10229 requires android.permission.WRITE_EXTERNAL_STORAGE, or grantUriPermission() W/System.err( 8810): at android.os.Parcel.createException(Parcel.java:1942) W/System.err( 8810): at android.os.Parcel.readException(Parcel.java:1910) W/System.err( 8810): at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:183) W/System.err( 8810): at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135) W/System.err( 8810): at android.content.ContentProviderProxy.insert(ContentProviderNative.java:476) W/System.err( 8810): at android.content.ContentResolver.insert(ContentResolver.java:1587) W/System.err( 8810): at vn.hunghd.flutterdownloader.DownloadWorker.addImageOrVideoToGallery(DownloadWorker.java:566) W/System.err( 8810): at vn.hunghd.flutterdownloader.DownloadWorker.downloadFile(DownloadWorker.java:356) W/System.err( 8810): at vn.hunghd.flutterdownloader.DownloadWorker.doWork(DownloadWorker.java:189) W/System.err( 8810): at androidx.work.Worker$1.run(Worker.java:85) W/System.err( 8810): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) W/System.err( 8810): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) W/System.err( 8810): at java.lang.Thread.run(Thread.java:764) I/WM-WorkerWrapper( 8810): Worker result FAILURE for Work [ id=64cb9110-f8c2-4d98-bb0d-65152c780389, tags={ flutter_download_task, vn.hunghd.flutterdownloader.DownloadWorker } ]

jiyangjjj commented 4 years ago

@roychenggit @jiyangjjj This is what you are supposed to do <application android:name=".MyApplication"...>

I found it still works with this error……Maybe it's not necessary to deal .

jvzaniolo commented 4 years ago

I'm trying to download an apk file and I'm getting the same error --- Failed to create image decoder with message 'unimplemented'

My functions are the same as the example project, but I don't have all of them. Can you tell me what am I missing? @hnvn

To get Local Path: Future<String> _findLocalPath() async { final directory = Theme.of(context).platform == TargetPlatform.android ? await getExternalStorageDirectory() : await getApplicationDocumentsDirectory(); return directory.path; }

To get permission: Future<bool> _checkPermission() async { if (Theme.of(context).platform == TargetPlatform.android) { PermissionStatus permission = await PermissionHandler() .checkPermissionStatus(PermissionGroup.storage); if (permission != PermissionStatus.granted) { Map<PermissionGroup, PermissionStatus> permissions = await PermissionHandler() .requestPermissions([PermissionGroup.storage]); if (permissions[PermissionGroup.storage] == PermissionStatus.granted) { return true; } } else { return true; } } else { return true; } return false; }

And to download the file: `Future downloadFromUrl() async { await _checkPermission(); final _localPath = (await _findLocalPath()) + Platform.pathSeparator + 'Download';

final saveDir = Directory(_localPath);
bool hasExisted = await saveDir.exists();
if (!hasExisted) {
  await saveDir.create();
}

return await FlutterDownloader.enqueue(
  url: url,
  fileName: 'Target APK',
  savedDir: _localPath,
  showNotification: true,
  openFileFromNotification: true,  // this doesn't work as well. If I click on the notification nothing happens
);

}`

PS: Sorry for my english. It's not my first language.

j574144 commented 4 years ago

this problem persist, please any help.

johnny-stevie commented 4 years ago

If it's any help,I unistalled and reinstalled the pub package, made sure that the image was still there. In my case, the download gave the same decoder error but the image was saved anyway. Code that worked for me: String imageTask = await FlutterDownloader.enqueue( url:coverArt, savedDir: dir.path+"/Images/", fileName: songName+".jpg", showNotification: true, openFileFromNotification: true );

On Wed, 18 Mar 2020 at 04:44, Joaquin Lozano Cifuentes < notifications@github.com> wrote:

this problem persist, please any help.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/fluttercommunity/flutter_downloader/issues/113#issuecomment-600422214, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKHDUOBPTBOKPX3KJI465L3RIBGUFANCNFSM4IS6OTWA .

Hardik184code commented 2 years ago

I have some error in decode Image. I Try To Many Solutions But No Result Found. So Someone Tell Right Answer And what is actual issued in my project.

E/FlutterJNI( 4220): Failed to decode image E/FlutterJNI( 4220): android.graphics.ImageDecoder$DecodeException: Failed to create image decoder with message 'unimplemented'Input contained an error. E/FlutterJNI( 4220): at android.graphics.ImageDecoder.nCreate(Native Method) E/FlutterJNI( 4220): at android.graphics.ImageDecoder.access$200(ImageDecoder.java:173) E/FlutterJNI( 4220): at android.graphics.ImageDecoder$ByteBufferSource.createImageDecoder(ImageDecoder.java:250) E/FlutterJNI( 4220): at android.graphics.ImageDecoder.decodeBitmapImpl(ImageDecoder.java:1862) E/FlutterJNI( 4220): at android.graphics.ImageDecoder.decodeBitmap(ImageDecoder.java:1855) E/FlutterJNI( 4220): at io.flutter.embedding.engine.FlutterJNI.decodeImage(FlutterJNI.java:524)

sivaswensa commented 2 years ago

I'm getting this error while playing the youtube video in android device, Can anyone solve this issue

E/FlutterJNI(10779): Failed to decode image E/FlutterJNI(10779): android.graphics.ImageDecoder$DecodeException: Failed to create image decoder with message 'unimplemented'Input contained an error. E/FlutterJNI(10779): at android.graphics.ImageDecoder.nCreate(Native Method) E/FlutterJNI(10779): at android.graphics.ImageDecoder.access$200(ImageDecoder.java:178) E/FlutterJNI(10779): at android.graphics.ImageDecoder$ByteBufferSource.createImageDecoder(ImageDecoder.java:248) E/FlutterJNI(10779): at android.graphics.ImageDecoder.decodeBitmapImpl(ImageDecoder.java:1896) E/FlutterJNI(10779): at android.graphics.ImageDecoder.decodeBitmap(ImageDecoder.java:1889) E/FlutterJNI(10779): at io.flutter.embedding.engine.FlutterJNI.decodeImage(FlutterJNI.java:514)

tejaswinidev24 commented 1 year ago

I am also facing the same issue

E/FlutterJNI(11830): Failed to decode image E/FlutterJNI(11830): android.graphics.ImageDecoder$DecodeException: Failed to create image decoder with message 'unimplemented'Input contained an error. E/FlutterJNI(11830): at android.graphics.ImageDecoder.nCreate(Native Method) E/FlutterJNI(11830): at android.graphics.ImageDecoder.access$200(ImageDecoder.java:173) E/FlutterJNI(11830): at android.graphics.ImageDecoder$ByteBufferSource.createImageDecoder(ImageDecoder.java:250) E/FlutterJNI(11830): at android.graphics.ImageDecoder.decodeBitmapImpl(ImageDecoder.java:1847) E/FlutterJNI(11830): at android.graphics.ImageDecoder.decodeBitmap(ImageDecoder.java:1840) E/FlutterJNI(11830): at io.flutter.embedding.engine.FlutterJNI.decodeImage(Unknown Source:16)

Lonyless commented 1 year ago

I am also facing the same issue