【问题标题】:(No implementation found for method canLaunch on channel plugins.flutter.io...)(在通道 plugins.flutter.io 上找不到方法 canLaunch 的实现...)
【发布时间】:2021-10-06 12:37:37
【问题描述】:

enter image description here我正在构建一个使用firebase的应用程序并共享应用程序的内容 该应用程序运行良好,当我添加 firebase 包时出现错误:

MissingPluginException(在通道 plugins.flutter.io/url_launcher 上找不到方法 canLaunch 的实现)

MissingPluginException(在通道 plugins.flutter.io/share 上找不到方法 canLaunch 的实现)

MissingPluginException(在通道 plugins.flutter.io/google_mobile_ads 上找不到方法 canLaunch 的实现)

我尝试了不止一种方法 (扑干净)很多次 (flutter pub get) 多次 (颤抖着跑) (重新安装应用程序)多次 我搜索了解决方案,但没有成功

class Home extends StatefulWidget {
static String id = 'HomeScreen';
const Home({Key? key}) : super(key: key);

@override
_HomeScreenState createState() => _HomeScreenState();
 }

class _HomeScreenState extends State<Home> {

Future<InitializationStatus> _initGoogleMobileAds() {
return MobileAds.instance.initialize();
}


 late BannerAd _bannerAd;

 bool _isBannerAdReady = false;

  @override
  void initState() {
 _bannerAd = BannerAd(
  adUnitId: AdHelper.bannerAdUnitId,
  request: AdRequest(),
  size: AdSize.banner,
  listener: BannerAdListener(
    onAdLoaded: (_) {
    setState(() {
      _isBannerAdReady = true;
    });
    },
    onAdFailedToLoad: (ad, err) {
     print('Failed to load a banner ad: ${err.message}');
     _isBannerAdReady = false;
      ad.dispose();
    },
  ),
 );

 _bannerAd.load();
 enter image description here}


 @override
 void dispose() {
  _bannerAd.dispose();
  super.dispose();
 }}

我在具有 _launchUrl() 的同一类中添加了广告

    _launchURL() async {
    const url = 'url';
    if (await canLaunch(url)) {
    await launch(url);
    } else {
  throw 'Could not launch $url';
   }
  }

还有 _share() 方法

         onTap: () {
           Share.share(appUrl);
              },

【问题讨论】:

  • 你在哪里使用canLaunch()
  • 请分享导致这些异常的代码。
  • 查看How to Ask 来改进这个问题
  • 你好,谢谢帮助 我在具有方法 _launchUrl() 的同一类中添加了广告
  • @PeterKoltai @ Alex.F

标签: flutter flutter-layout flutter-dependencies flutter-web flutter-test


【解决方案1】:

我得到了答案 我正在使用flutter_facebook_auth 包:阅读文档时enter link description here

安装此插件时,您需要在 Android 上配置该插件,然后才能再次运行该项目。如果您不这样做,您将遇到 No implementation found 错误,因为 Android 上的 facebook SDK 在尚未定义配置时会抛出异常,这会锁定您项目中的其他插件。如果您还不需要该插件,请删除或评论它。

【讨论】:

    猜你喜欢
    • 2021-07-10
    • 1970-01-01
    • 2020-07-16
    • 2020-01-24
    • 2019-12-01
    • 2022-10-22
    • 2020-12-09
    • 2019-09-06
    相关资源
    最近更新 更多