Resolving ERR_UNKNOWN_URL_SCHEME Errors

Encountering the ERR_UNKNOWN_URL_SCHEME error can be a hiccup in the seamless operation and user experience of an Android app, particularly when incorporating web content directly within the app using WebView. This error typically surfaces when the app attempts to access or render a web page with a URL scheme that the mobile device does not recognize or support, leading to frustration for both developers and users alike.

Understanding the ERR_UNKNOWN_URL_SCHEME error

The crux of the ERR_UNKNOWN_URL_SCHEME error lies in the interaction between the app and web content through WebView—a component that allows web pages to be displayed directly within the app. However, when WebView encounters a URL with a scheme other than the familiar ‘http://’ or ‘https://’, such as ‘mailto://’, ‘telnet://’, or custom schemes like ‘app://’, it may not know how to process these requests, resulting in the aforementioned error.

What is WebView?

WebView is a pivotal component for Android apps, allowing developers to include web content as part of the application’s layout.

The err_unknown_url_scheme error appears when things go awry with WebView, an Android native development tool appearing in apps from the Google play store which appears in this image.

Instead of redirecting users to a web browser, WebView displays web pages directly within the app. This integration ensures that users enjoy a consistent UX, free from the disruption of switching between the app and an external browser.

Despite its capability to render web pages, WebView intentionally lacks the full array of features found in a standalone web browser. Users won’t find a search bar, navigation controls, or other browser-specific functionalities. However, WebView’s focus is on seamlessly displaying web content, ensuring that the core app experience remains fluid and uninterrupted.

Those familiar with WebView are probably already acquainted with Android Studio, whose website is pictured here.

The challenge of ERR_UNKNOWN_URL_SCHEME errors

While WebView opens up new possibilities for integrating web content, it’s not without its challenges. A notable issue that developers may encounter is the ERR_UNKNOWN_URL_SCHEME error. This error arises when WebView attempts to process a URL with a scheme that is not natively recognized by the mobile device, such as ‘mailto://’, ‘whatsapp://’, or ‘file://’. These non-standard URL schemes can disrupt the intended behavior of WebView, leading to an error message instead of the desired web content.

WebView’s utility in native apps is undeniable, yet its functionality is tailored to handle primarily the standard ‘https://’ and ‘http://’ URL schemes. When developers or users encounter the ERR_UNKNOWN_URL_SCHEME error, it indicates a mismatch between WebView’s capabilities and the URL scheme being requested.

Causes of ERR_UNKNOWN_URL_SCHEME errors

The error typically stems from one of two scenarios:

Non-Standard URL Schemes: WebView struggles with URL schemes outside the conventional ‘http://’ and ‘https://’. Schemes like ‘mailto://’, ‘whatsapp://’, and ‘intent://’ are designed for specific actions (e.g., opening an email client or initiating a WhatsApp message) and require specialized handling within the app’s code to function correctly in WebView.

Redirected URLs and OAuth Integration: Another common trigger for the ERR_UNKNOWN_URL_SCHEME error is when a user is redirected to a URL that employs an unrecognized scheme. Similarly, integrating OAuth authentication with custom Chrome cards can lead to this error if the redirect URI uses a scheme not supported by WebView.

Mitigating ERR_UNKNOWN_URL_SCHEME warnings

For developers, addressing the ERR_UNKNOWN_URL_SCHEME error involves a nuanced understanding of URL schemes and WebView’s limitations. Implementing specific URL coding practices to handle or avoid non-standard schemes gracefully is crucial. This may include configuring the app to open certain links in an external browser or incorporating intent filters to manage how these URLs are processed.

Solving ERR_UNKNOWN_URL_SCHEME errors

Addressing this error requires a dual approach, focusing on both front-end solutions for users and back-end fixes for developers:

For end-users:

Disable Chrome extensions

  1. Open Chrome and navigate to `chrome://extensions/`.
    To resolve the err_file_not_found error, go to Chrome's menu and click on extensions, manage extensions.
  2. Temporarily disable all extensions by toggling the switch at the bottom right corner of each extension card.
    Chrome's manage extensions screen showing cards with toggles to disable or enable each extension.
  3. If the error disappears, re-enable extensions one by one to identify the culprit, then remove or update it.

Clear the Chrome cache and cookies

  1. Go to Chrome Settings > More Tools > Clear Browsing Data.
    Clearing Chrome's browsing data.
  2. Choose “Cached images and files” (and “Cookies and other site data” if desired).
    Clear data button in Chrome for clearing the browser cache.
  3. Select the time range and click “Clear data”.

Turn off hardware acceleration

  1. In Chrome Settings, scroll down to the System section.
  2. Toggle off “Use hardware acceleration when available”.
  3. Relaunch Chrome to apply changes.

Disable your firewall

For Windows:

  1. Press `Win + R`, type `control`, and hit Enter to open the Control Panel.
  1. Click on “System and Security”, then click on “Windows Defender Firewall”.
    Firewall and network protection in Windows Security settings.
  1. On the left sidebar, you’ll find an option labeled “Turn Windows Defender Firewall on or off”. Click on it.
    Windows firewall settings with firewalls turned off and highlighted.
  1. You’ll see your network settings divided into “Private network settings” and “Public network settings”. To disable the firewall, check the boxes under each section that say “Turn off Windows Defender Firewall (not recommended)”.
  1. Click on “OK” to save your changes.

Remember, turning off your firewall can make your device more vulnerable to unauthorized access. Always turn it back on as soon as you’re done troubleshooting.

For macOS:

  1. Click on the Apple menu at the top left corner of your screen and select “System Preferences”.
  1. Find and click on “Security & Privacy”.
  1. In the “Security & Privacy” window, go to the “Firewall” tab.
    Turning off the firewall on a Mac. Turn it back on when finished troubleshooting.
  1. Click the lock icon at the bottom left to make changes. You might need to enter your administrator password.
  1. Click on “Turn Off Firewall” to disable it.
  1. Re-lock the settings by clicking the lock icon again.

As with Windows, remember to re-enable your firewall once you’ve finished troubleshooting to keep your device secure.

Creating a new Chrome user profile

Creating a new Chrome profile can help isolate browser issues to a specific user environment, making it easier to diagnose problems like the ERR_UNKNOWN_URL_SCHEME error without affecting your main browsing experience.

  1. Launch the Google Chrome browser on your computer.
  1. Click on the Profile icon in the upper right corner of the Chrome window. It might show your current profile picture or a default icon if you haven’t personalized it.
    Chrome's kebab menu expanded to show the Add new profile option under user profile.
  1. In the dropdown menu, click on the “Add” button or “+ Add” to start creating a new profile.
  1. You’ll be prompted to name the new profile. You can also choose a theme color and an avatar to distinguish it from other profiles.
  1. You have the option to sign in with a Google Account, which will sync your bookmarks, history, passwords, and other Chrome settings across all your devices. This step is optional; you can choose “Continue without an account” to proceed.
    An example of what Chrome users might see while setting up a new user profile, this time to rid themselves of the err_unknown_url_scheme error.
  2. Once you’ve customized your profile, click on “Done”. Chrome will open a new window with the newly created profile.
  1. To switch between profiles, click on your profile icon in the Chrome toolbar and select another profile from the list.
    Switching between different profiles in Chrome's user profiles to check if that solves the err_unknown_url_scheme error.

For developers:

Open the URL in a new window

For web developers, ensuring links that require specific URL schemes (not http/https) open in a new window can sometimes bypass the error:

<a href="your-custom-url-scheme://" target="_blank">Open in App</a>

This can be a temporary fix but consider user experience implications.

Add a new intent for Android apps

If developing for Android and using WebView, override `shouldOverrideUrlLoading` to handle specific URL schemes with an Intent:

@Override

public boolean shouldOverrideUrlLoading(WebView view, String url) {

 if (url.startsWith("http://") || url.startsWith("https://")) {

 return false;

 }

 Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));

 startActivity(intent);

 return true;

}

This allows your app to open URLs with unrecognized schemes in the appropriate external application.

Disable non-standard URL schemes

To avoid the ERR_UNKNOWN_URL_SCHEME error, you might opt to restrict URL loading to http and https schemes only:

@Override

public boolean shouldOverrideUrlLoading(WebView view, String url) {

 if (url.startsWith("http://") || url.startsWith("https://")) {

 view.loadUrl(url);

 return true;

 } else {

 // Handle unknown URL scheme

 return false;

 }

}

Handle custom URL schemes appropriately

Ensure that your application or website properly handles custom URL schemes, especially if they are essential to your application’s functionality. This may involve setting up intent filters for Android applications or configuring URL scheme handlers for web applications.

Use fallback mechanisms for custom URL schemes

Implement a fallback mechanism in case the primary action (like opening a custom scheme URL) fails. This can be done by detecting the error and then redirecting the user to a web page or showing a message explaining how to manually complete the action the URL scheme was supposed to trigger.

Summary

The ERR_UNKNOWN_URL_SCHEME error, while primarily a development issue, can also be mitigated by users through browser troubleshooting steps. For developers, understanding and implementing solutions such as adding specific intents or modifying how URLs are handled within WebView are crucial steps towards creating a more robust and user-friendly Android app. Ensuring web content renders seamlessly within an app not only enhances UX but also maintains the integrity and functionality of the app’s features.

Get a head start on website creation with AI

Create a custom website tailored to your business needs 10X faster with 10Web AI Website Builder!

No credit card required

Share article

Leave a comment

Your email address will not be published. Required fields are marked *

Your email address will never be published or shared. Required fields are marked *

Comment*

Name *