FLUTTER: url_launcher library and Android Package Visibility error

1.2k Views Asked by At

I am using url_launcher: to open youtube, instagram, facebook and telegram links from my app. It used to work fine until I upgraded to latest Flutter and Dart plugins.

When upgraded to latest versions of Flutter and Dart, canLaunch(url) function started to fail and from the documentation it appeared the I have to follow guidelines in compliance to Android Package Visibility as mentioned here; https://developer.android.com/training/package-visibility

It started to work on all devices and appeared to work well on all Android-11 devices and emulator as well. But it failed to open same links only on Samsung S20.

Any help? I am simply opening Youtube, Instagram, Telegram, Soundcloud and some other links through this function;

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

-- It throws 'Could not launch $url' error on S20 only., having Android-11

ANY HELP PLEASE???

I have modified AndroidManifest as following, after which it worked on most of the devices, but not working on 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>
1

There are 1 best solutions below

0
On

Would you try using other package?

https://pub.dev/packages/device_apps

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