0

I built an app in Flutter that has a link to my website. When I click on the link, the browser opens with an error code: "Unable to load page https://… because of net:ERR_CACHE_MISS".

pubspec.yaml

url_launcher: ^6.1.1

Mianifest.xml

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

Function call my websaid (example www.google.com):

Future<void> _launchUrl() async {
  final Uri _url = Uri.parse('https://www.google.com');
  if (!await launchUrl(_url)) {
    throw Exception('Could not launch $_url');
  }
}

If I additionally add to the Manifest:

<intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="http" />
        <data android:scheme="https" />
        <data android:host="www.google.com" />
</intent-filter>

, then the built application installs on the phone, but does not start or depending on the hardware, it starts, but only information about the application.


Flutter 3.10.6 • channel stable • https://github.com/flutter/flutter.git Framework • revision f468f3366c (5 weeks ago) • 2023-07-12 15:19:05 -0700 Engine • revision cdbeda788a
Tools • Dart 3.0.6 • DevTools 2.23.1

2
  • I use url_launcher 6.1.7 but I did not have to add a queries section to my AndroidManifest.xml file. And I doubt you need those intent-filters. What happens when you remove all of that from your AndroidManifest.xml file? (I'm testing on a device running Android 13). Commented Aug 14, 2023 at 22:25
  • I updated to version 1.6.1 and deleted <intent-filter> I am receiving the same error: "Unable to load page https://… because of net:ERR_CACHE_MISS". Commented Aug 17, 2023 at 20:30

2 Answers 2

1

Make sure your AndroidManifest.xml file has the following permission specified:

<uses-permission android:name="android.permission.INTERNET"/>

According to the documentation for url_launcher you only need the queries section changes if you are trying to use the canLaunchUrl method.

And you definitely do not want those intent-filter changes. Those are mainly for having Android use your app when someone tries to open those types of URLs from other apps. For example, if you wanted when someone shares a link to your website for it to open your app instead of the normal browser.

Sign up to request clarification or add additional context in comments.

1 Comment

<uses-permission android:name="android.permission.INTERNET"/> resolved problem. Thank You.
0

Use the updated one, if possible: url_launcher: ^6.1.10

Add this to AndroidManifest.xml

<queries>
    <!-- If your app opens https URLs -->
    <intent>
        <action android:name="android.intent.action.VIEW" />
        <data android:scheme="https" />
    </intent>
    <!-- If your app makes calls -->
    <intent>
        <action android:name="android.intent.action.DIAL" />
        <data android:scheme="tel" />
    </intent>
    <!-- If your sends SMS messages -->
    <intent>
        <action android:name="android.intent.action.SENDTO" />
        <data android:scheme="smsto" />
    </intent>
    <!-- If your app sends emails -->
    <intent>
        <action android:name="android.intent.action.SEND" />
        <data android:mimeType="*/*" />
    </intent>
</queries>

Define this method.

launchurl(String targetUrl) async {
  final url = targetUrl;
  if (await canLaunch(url)) {
    await launch(url);
  } else {
    throw "cannot launch $url";
  }
}

Call this method anywhere(onTap/onPressed) you want by passing your target URL as a String.

1 Comment

I am receiving the following messages - 'canLaunch' is deprecated and shouldn't be used. Use canLaunchUrl instead. - 'launch' is deprecated and shouldn't be used. Use launchUrl instead. that’s why I use Future<void> _launchUrl() async { final Uri _url = Uri.parse('google.com'); if (!await launchUrl(_url)) { throw Exception('Could not launch $_url'); } } - I added <queries>.... I am receiving the same error: "Unable to load page https://… because of net:ERR_CACHE_MISS".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.