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

Uncaught Error: MissingPluginException #853

Open
bin2ai opened this issue Nov 7, 2024 · 1 comment
Open

Uncaught Error: MissingPluginException #853

bin2ai opened this issue Nov 7, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@bin2ai
Copy link

bin2ai commented Nov 7, 2024

Flutter Version

My version : 3.24.4

Lib Version

My version : ^3.1.1

Platform (Android / iOS / web) + version

Platform : Web Deployed and Test on...

  • Microsoft Edge: Version 130.0.2849.68 (Official build) (64-bit)
  • Google Chrome: Version 130.0.6723.93 (Official Build) (64-bit)
  • Safari 18 on iOS 18

Describe the bug

[√] I can run flutter run -d chrome (tested web only) and have the audio play just fine.
[X] however, when i deploy to the internet using firebase (firebase deploy) no sound is played an the network console prints the founding messages (2 warnings, 1 error).

MissingPluginException(No implementation found for method stop on channel assets_audio_player)
MissingPluginException(No implementation found for method open on channel assets_audio_player)
Uncaught Error: MissingPluginException(No implementation found for method open on channel assets_audio_player)

Flutter doctor

[√] Flutter (Channel stable, 3.24.4, on Microsoft Windows [Version 10.0.22631.4391], locale en-US)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[X] Android toolchain - develop for Android devices
    X Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/to/windows-android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.

[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Build Tools 2019 16.11.32)
[!] Android Studio (not installed)
[√] VS Code (version 1.95.1)
[√] Connected device (3 available)
[√] Network resources

Small code to reproduce
main.dart

import 'package:assets_audio_player/assets_audio_player.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State {
  
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: RaisedButton(
            child: Text("open"),
            onPressed: () {
                        AssetsAudioPlayer.newPlayer()
              .open(Audio('assets/sound.mp3'), autoStart: true);
            }
          ),
        ),
      ),
    );
  }
}

pubspec.yaml

dependencies:
  flutter:
    sdk: flutter
  #...
  assets_audio_player: ^3.1.1
  #...
  assets:
    - assets/sound.mp3
  #...
@bin2ai bin2ai added the bug Something isn't working label Nov 7, 2024
@EirikFaerdin
Copy link

I have the same problem, so I have done some testing based on @bin2ai's test code. When debugging, I get a very strange behaviour inside the Future _open in assets_audio_player.dart as code lines are skipped after invoking the open method.

I use a local copy, so have added some debugging code (which yet does not help me much).

Code from the invokeMethod:

        final result = await _sendChannel.invokeMethod('open', params); //Break point here. Then press F8

        //Code below this is skipped
        print('Result: $result');
        if (result == true) {
          print('Audio file open ok');
        } else {
          print('Failed to open audio file');
        }

        await setLoopMode(_loopMode);

        _stopped = false;
        _playlistFinished.add(false);

        //Code above this is skipped
        _isBuffering.add(false); //Skips all lines up to this code after invoking the open method above pressing F8
      } on PlatformException {
        final errorHandler = ErrorHandler(
          player: this,
          currentPosition: currentPosition.value,
          playlist: _playlist?.playlist,
          playlistIndex: _playlist?.playlistIndex,
          error: AssetsAudioPlayerError(
            errorType: AssetsAudioPlayerErrorType.Player, message: '',),
        );
        if (onErrorDo != null) {
          onErrorDo!(errorHandler);
        }
      } catch (e) {
        _lastOpenedAssetsAudio = currentAudio; // revert to the previous audio
        _current.add(null);
        _isBuffering.add(false);
        _currentPosition.add(Duration.zero);
        try {
          await stop();
        } catch (t) {
          print(t);
        }
        print(e);
        return Future.error(e);
      }
    }
  }

I have a break point on the invokeMethod. When pressing F8 (Android Studio latest), it skips directly to the line as indicated in the comments in the code snippet (_isBuffering.add(false);).
Then it goes into the catch (e) and catch (t) which then outputs these errors:

MissingPluginException(No implementation found for method stop on channel assets_audio_player)
MissingPluginException(No implementation found for method open on channel assets_audio_player)
RethrownDartError: MissingPluginException(No implementation found for method open on channel assets_audio_player)

dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 329:10 createErrorWithStack
dart-sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart 265:28 _throw
dart-sdk/lib/core/errors.dart 120:5 throwWithStackTrace
dart-sdk/lib/async/zone.dart 1386:11 callback
dart-sdk/lib/async/schedule_microtask.dart 40:11 _microtaskLoop
dart-sdk/lib/async/schedule_microtask.dart 49:5 _startMicrotaskLoop
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 181:7

Needless to say, no audio is ever played.

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

3 participants