g123k / flutter_plugin_device_apps

Flutter plugin to get the list of installed applications (iOS is not supported yet).
https://pub.dev/packages/device_apps
Apache License 2.0
106 stars 87 forks source link

Unhandled Exception: type 'List<dynamic>' is not a subtype of type 'FutureOr<List<Application>>' #13

Open bardram opened 5 years ago

bardram commented 5 years ago

Sometimes I get the following error:

E/MethodChannel#g123k/device_apps(  791): Failed to handle method call
E/MethodChannel#g123k/device_apps(  791): java.util.concurrent.RejectedExecutionException: Task fr.g123k.deviceapps.DeviceAppsPlugin$2@91da73e rejected from java.util.concurrent.ThreadPoolExecutor@50276a8[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 11]
E/MethodChannel#g123k/device_apps(  791):   at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2078)
E/MethodChannel#g123k/device_apps(  791):   at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:843)
E/MethodChannel#g123k/device_apps(  791):   at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1389)
E/MethodChannel#g123k/device_apps(  791):   at fr.g123k.deviceapps.AsyncWork.run(AsyncWork.java:19)
E/MethodChannel#g123k/device_apps(  791):   at fr.g123k.deviceapps.DeviceAppsPlugin.fetchInstalledApps(DeviceAppsPlugin.java:105)
E/MethodChannel#g123k/device_apps(  791):   at fr.g123k.deviceapps.DeviceAppsPlugin.onMethodCall(DeviceAppsPlugin.java:61)
E/MethodChannel#g123k/device_apps(  791):   at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:222)
E/MethodChannel#g123k/device_apps(  791):   at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:90)
E/MethodChannel#g123k/device_apps(  791):   at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:234)
E/MethodChannel#g123k/device_apps(  791):   at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#g123k/device_apps(  791):   at android.os.MessageQueue.next(MessageQueue.java:325)
E/MethodChannel#g123k/device_apps(  791):   at android.os.Looper.loop(Looper.java:142)
E/MethodChannel#g123k/device_apps(  791):   at android.app.ActivityThread.main(ActivityThread.java:6944)
E/MethodChannel#g123k/device_apps(  791):   at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#g123k/device_apps(  791):   at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
E/MethodChannel#g123k/device_apps(  791):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
I/flutter (  791): PlatformException(error, Task fr.g123k.deviceapps.DeviceAppsPlugin$2@91da73e rejected from java.util.concurrent.ThreadPoolExecutor@50276a8[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 11], null)
E/flutter (  791): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: type 'List<dynamic>' is not a subtype of type 'FutureOr<List<Application>>'
E/flutter (  791): #0      _FutureListener.handleError (dart:async/future_impl.dart:144:7)
E/flutter (  791): #1      Future._propagateToListeners.handleError (dart:async/future_impl.dart:651:47)
E/flutter (  791): #2      Future._propagateToListeners (dart:async/future_impl.dart:672:24)
E/flutter (  791): #3      Future._completeError (dart:async/future_impl.dart:491:5)
E/flutter (  791): #4      _SyncCompleter._completeError (dart:async/future_impl.dart:55:12)
E/flutter (  791): #5      _Completer.completeError (dart:async/future_impl.dart:27:5)
E/flutter (  791): #6      _AsyncAwaitCompleter.completeError (dart:async-patch/async_patch.dart:40:18)
E/flutter (  791): #7      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart)
E/flutter (  791): <asynchronous suspension>
E/flutter (  791): #8      DeviceApps.getInstalledApplications (package:device_apps/device_apps.dart:14:21)
E/flutter (  791): <asynchronous suspension>
E/flutter (  791): #9      AppsProbe.getDatum (package:carp_mobile_sensing/sampling_packages/apps/app_probes.dart:16:47)
E/flutter (  791): <asynchronous suspension>
E/flutter (  791): #10     PeriodicDatumProbe.onResume.<anonymous closure> (package:carp_mobile_sensing/runtime/probes.dart:383:9)
E/flutter (  791): <asynchronous suspension>
E/flutter (  791): #11     _rootRunUnary (dart:async/zone.dart:1132:38)
E/flutter (  791): #12     _CustomZone.runUnary (dart:async/zone.dart:1029:19)
E/flutter (  791): #13     _CustomZone.runUnaryGuarded (dart:async/zone.dart:931:7)
E/flutter (  791): #14     _CustomZone.bindUnaryCallbackGuarded.<anonymous closure> (dart:async/zone.dart:968:26)
E/flutter (  791): #15     _rootRunUnary (dart:async/zone.dart:1136:13)
E/flutter (  791): #16     _CustomZone.runUnary (dart:async/zone.dart:1029:19)
E/flutter (  791): #17     _CustomZone.bindUnaryCallback.<anonymous closure> (dart:async/zone.dart:952:26)
E/flutter (  791): #18     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:382:19)
E/flutter (  791): #19     _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:416:5)
E/flutter (  791): #20     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:171:12)

I can't really explain when; sometimes the call to getInstalledApplications() works just fine. Other times, I get the above exception. It's seems like every 2nd time I call the method, I get the exception.

g123k commented 5 years ago

Hello,

Which version of the library are you using?

bardram commented 5 years ago

Version 1.0.8