Open dochanhca opened 4 years ago
Thank you for submitting this issue. Would you be able to supply a small example which reproduces this bug?
Also which version of the plugin are you using? We did implement support for Add-2-app features since 4.4.0.
I am asking for an example since I am not sure what you mean with “start FlutterEngine with FlutterFragment”
I'm using plugin ver 4.4.0+hotfix.2. I'm import my flutter project as a module inside Android native app.
public class VietJetFlutterFragment extends FlutterFragment {
@Override
public FlutterEngine provideFlutterEngine(Context context) {
FlutterEngine flutterEngine = new FlutterEngine(context);
flutterEngine.getDartExecutor().executeDartEntrypoint(
DartExecutor.DartEntrypoint.createDefault()
);
GeneratedPluginRegistrant.registerWith(flutterEngine);
return flutterEngine;
}
}
flutterFragment = new VietJetFlutterFragment();
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.add(R.id.fr_vietjet, flutterFragment, flutterFragment.getClass().getSimpleName());
fragmentTransaction.commit();
Generated code from Flutter Engine:
@Keep
public final class GeneratedPluginRegistrant {
public static void registerWith(@NonNull FlutterEngine flutterEngine) {
ShimPluginRegistry shimPluginRegistry = new ShimPluginRegistry(flutterEngine);
flutter.plugins.contactsservice.contactsservice.ContactsServicePlugin.registerWith(shimPluginRegistry.registrarFor("flutter.plugins.contactsservice.contactsservice.ContactsServicePlugin"));
flutterEngine.getPlugins().add(new io.flutter.plugins.deviceinfo.DeviceInfoPlugin());
io.github.ponnamkarthik.toast.fluttertoast.FluttertoastPlugin.registerWith(shimPluginRegistry.registrarFor("io.github.ponnamkarthik.toast.fluttertoast.FluttertoastPlugin"));
io.scer.pdf.renderer.NativePDFRendererPlugin.registerWith(shimPluginRegistry.registrarFor("io.scer.pdf.renderer.NativePDFRendererPlugin"));
flutterEngine.getPlugins().add(new io.flutter.plugins.pathprovider.PathProviderPlugin());
flutterEngine.getPlugins().add(new com.baseflow.permissionhandler.PermissionHandlerPlugin());
flutterEngine.getPlugins().add(new io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin());
flutterEngine.getPlugins().add(new io.flutter.plugins.urllauncher.UrlLauncherPlugin());
}
}
I have same issue. I use flutter module as aar and import into android project as a fragment. Android 9 and earlier working fine. But android 10, sometimes it will ask permission, sometimes doesn't. I don't know why. Error:
[ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(PermissionHandler.PermissionManager, Android activity is required to check for permissions and cannot be null., null)
#1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:321:33)
<asynchronous suspension>
#2 MethodChannelPermissionHandler.checkPermissionStatus (package:permission_handler_platform_interface/src/method_channel/method_channel_permission_handler.dart:15:41)
#3 PermissionActions.status (package:permission_handler/permission_handler.dart:25:51)
Any suggestion on this issue? Currently having this issue with steps explained above. @dochanhca were you bale to resolve this issue?
Same issue here, FlutterFragment
class not trigged onAttachedToActivity
, so I missed all plugin features.
Do we have any update here ? :) I figure out the problem. I copy/paste the exemple dart page into an empty flutter module project, when I run it, I have any errors around missing methods on message channel. But once I embded it in a fragment, all the methods used by the plugins is not implemented.
🐛 Bug Report
Maybe method startListening() not being called when I start flutter engine with FlutterFragment. Because doesn't fired on onAttachedToActivity(@NonNull ActivityPluginBinding binding)? So I getting this exception when trying to check permission: MissingPluginException(No implementation found for method checkPermissionStatus on channel flutter.baseflow.com/permissions/methods).
Expected behavior
Reproduction steps
When I call : final PermissionStatus statusFuture = await PermissionHandler() .checkPermissionStatus(PermissionGroup.contacts); I getting this error: `[ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method checkPermissionStatus on channel flutter.baseflow.com/permissions/methods)
0 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:319:7)
Configuration
Platform: