Skip to content
This repository has been archived by the owner on Jan 20, 2023. It is now read-only.

MissingPluginException, Flutter 0.8.2 and up #10

Closed
trillom opened this issue Oct 9, 2018 · 1 comment
Closed

MissingPluginException, Flutter 0.8.2 and up #10

trillom opened this issue Oct 9, 2018 · 1 comment

Comments

@trillom
Copy link

trillom commented Oct 9, 2018

I'm receiving the following error: MissingPluginException(No implementation found for method crypto_box_keypair on channel flutter_sodium)

I've tried reloads, restarts, starting a new project with JUST the offending code, deleting generated files and rebuilding, nothing works. Code below.

  • Flutter 0.8.2 and 0.9.6
  • Android Studio 3.2
    • Build #AI-181.5540.7.32.5014246, built on September 17, 2018
    • JRE: 1.8.0_152-release-1136-b06 x86_64
    • JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
  • macOS 10.14

Example class:

import 'package:flutter_sodium/flutter_sodium.dart';

class KeygenTest {
  KeygenTest();

  Future<String> generateKeys () async {
    KeyPair keys = await CryptoBox.generateKeyPair();
    print (keys.toString());
    return "generated";
  }
}

Unit test:

import 'package:flutter_test/flutter_test.dart';
import 'keygen.dart';

void main() {
  group("keygen", () {
    test("generate key", () async {
      KeygenTest test = new KeygenTest();
      await test.generateKeys();
    });
  });
}

Full output:

$ flutter test lib/keygen.test.dart
00:12 +0 -1: keygen generate key [E]
  MissingPluginException(No implementation found for method crypto_box_keypair on channel flutter_sodium)
  package:flutter/src/services/platform_channel.dart 278:7  MethodChannel.invokeMethod
  ===== asynchronous gap ===========================
  dart:async                                                _AsyncAwaitCompleter.completeError
  package:flutter/src/services/platform_channel.dart        MethodChannel.invokeMethod
  ===== asynchronous gap ===========================
  dart:async                                                _asyncThenWrapperHelper
  package:flutter/src/services/platform_channel.dart        MethodChannel.invokeMethod
  package:flutter_sodium/flutter_sodium.dart 554:10         Sodium.cryptoBoxKeypair
@kozw
Copy link
Contributor

kozw commented Oct 11, 2018

Flutter plugins (including flutter_sodium) don't work in unit tests. Tests run completely headless, in a dart only environment. There's no Android or iOS runtime available.

You can mock a plugin, see https://docs.flutter.io/flutter/services/MethodChannel/setMockMethodCallHandler.html

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants