【问题标题】:FLUTTER: url_launcher library and Android Package Visibility error颤振:url_launcher 库和 Android 包可见性错误
【发布时间】:2021-05-12 04:17:03
【问题描述】:

我正在使用 url_launcher: 从我的应用程序中打开 youtube、instagram、facebook 和电报链接。在我升级到最新的 Flutter 和 Dart 插件之前,它一直运行良好。

当升级到最新版本的 Flutter 和 Dart 时,canLaunch(url) 函数开始失败,从文档看来,我必须遵循符合 Android 的准则此处提到的包可见性https://developer.android.com/training/package-visibility

它开始在所有设备上运行,并且似乎在所有 Android-11 设备和模拟器上运行良好。但它无法仅在三星 S20 上打开相同的链接。

有什么帮助吗?我只是通过这个功能打开 Youtube、Instagram、Telegram、Soundcloud 和其他一些链接;

static launchAction(String url) async {
    if (await canLaunch(url)) {
      await launch(url);
    } else {
      throw 'Could not launch $url';
    }
  }

-- 它仅在 S20 上引发“无法启动 $url”错误。具有 Android-11

ANY HELP PLEASE???

我修改了 AndroidManifest 如下,之后它在大多数设备上都可以工作,但不能在 SAMSUNG S20 上工作;

    <queries>
        <!-- Specific apps you interact with, eg: -->
        <package android:name="com.google.android.youtube" />
        <package android:name="com.facebook.katana" />
        <package android:name="com.instagram.android" />
        <package android:name="org.telegram.messenger" />
        <package android:name="com.soundcloud.android" />
    </queries>

【问题讨论】:

标签: android flutter flutter-dependencies android-11 url-launcher


【解决方案1】:

你会尝试使用其他包吗?

https://pub.dev/packages/device_apps

if (await DeviceApps.isAppInstalled('com.nbt.moves')) {
    DeviceApps.openApp('com.nbt.moves');
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-02
    • 2019-12-27
    • 1970-01-01
    • 2021-01-08
    • 1970-01-01
    • 2018-10-30
    相关资源
    最近更新 更多