carp.sensing-flutter
carp.sensing-flutter copied to clipboard
Unhandled Exception: No implementation found for method startBackgroundService on channel plugins.shounakmulay.com/foreground_sms_channel
We get this on probe initialization:
E/flutter (11673): [ERROR:flutter/runtime/dart_vm_initializer.cc(40)] Unhandled Exception: MissingPluginException(No implementation found for method startBackgroundService on channel plugins.shounakmulay.com/foreground_sms_channel)
E/flutter (11673): #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:365:7)
platform_channel.dart:365
E/flutter (11673): <asynchronous suspension>
E/flutter (11673):
This is probably because the listening is set up during initialization:
/// The [TextMessageProbe] listens to SMS messages and collects a
/// [TextMessage] every time a new SMS message is received.
///
/// Only works on Android.
class TextMessageProbe extends StreamProbe {
@override
Stream<Measurement> get stream => _textMessageProbeController.stream;
@override
bool onInitialize() {
if (!Platform.isAndroid) {
throw SensingException('TextMessageProbe only available on Android.');
}
Telephony.backgroundInstance.listenIncomingSms(
onNewMessage: (SmsMessage message) {
_textMessageProbeController.add(
Measurement.fromData(TextMessage.fromSmsMessage(message)),
);
},
onBackgroundMessage: backgroundMessageHandler,
);
return true;
}
}
This should probably be done in the start() method.
Several observations:
- It seems to be a problem when running in debug mode in Flutter - when "running", there seems not to be a problem.
- Try to delete the
GeneratedPluginRegistrantfile (Java or Kotlin). - Run
flutter clean. - Clean graddle - from the android folder, run
./gradlew clean.