d-silveira / flutter-share

complete flutter share plugin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MissingPluginException

Mariluk opened this issue · comments

I/flutter (29128): The following MissingPluginException was thrown while activating platform stream on channel I/flutter (29128): plugins.flutter.io/receiveshare: I/flutter (29128): MissingPluginException(No implementation found for method listen on channel I/flutter (29128): plugins.flutter.io/receiveshare)

`Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, v0.7.3-pre.26, on Linux, locale cs_CZ.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
[✓] Android Studio (version 3.1)
[✓] IntelliJ IDEA Ultimate Edition (version 2018.1)
[✓] Connected devices (1 available)

• No issues found!
`

only in new project .. your example project after clone work fine

My pubspec:

dependencies:
flutter:
sdk: flutter
share:
git:
url: https://github.com/d-silveira/flutter-share.git

confirmed, same here.

After digging through how Flutter builds work and checking all the dependencies, turns out the problem is much simpler. The MainActivity that is created in a new project looks like that:

import android.os.Bundle;
import io.flutter.app.FlutterActivity;
import io.flutter.plugins.GeneratedPluginRegistrant;

public class MainActivity extends FlutterActivity {
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    GeneratedPluginRegistrant.registerWith(this);
  }
}

The thing is, for this plugin to work, you need not to extend FlutterActivity but FlutterShareReceiverActivity.

Change your MainActivity.java file content to reflect this change:

import android.os.Bundle;
import io.flutter.plugins.GeneratedPluginRegistrant;
import io.flutter.plugins.share.FlutterShareReceiverActivity;


public class MainActivity extends FlutterShareReceiverActivity {
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    GeneratedPluginRegistrant.registerWith(this);
  }
}

And everything will be fine (don't forget to import FlutterSharedReceiverActivity).Turns out, this is mentioned in the README, but like you, I missed it.

Hmm, but when I do this and I'm using path_provider plugin, it get's this error:

E/flutter (27478): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: MissingPluginException(No implementation found for method getApplicationDocumentsDirectory on channel plugins.flutter.io/path_provider)