Open links in browser with flutter

When using the url_launcher package for flutter, you may have run into the problem that canLaunch always returns false.

That’s because starting with Android 11 (API level 30) you have to explicitly request to „see“ other apps from yours. This is called package visibility and is explained in more detail here.

So we have to say, that we want to see apps that are capable of browsing the web. How do we do that?

In the AndroidManifest.xml we add the following:

            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="https" />

There is also a page on the android docs that explains this in further detail.

And now you rebuild your app aaand … maybe get the next error: resource linking failed /Users/sample/AndroidStudioProjects/MyApp/app/build/intermediates/merged_manifests/debug/AndroidManifest.xml:18: error: unexpected element <queries> found in <manifest>

That’s because you have to upgrade your gradle android plugin version as written here.

For that open the file build.gradle in your android folder and change the following line accordingly:

dependencies {

classpath ''

In this case I upgraded mine from 3.5.0 to 3.5.4 which now includes support for the queries tag in the AndroidManifest.xml.

Rebuild and your done!