As you’re trying out your new Android app, you’ll want to test its WebView. However, you may notice an error preventing a browser page from rendering within the app. This can negatively impact your app’s User Experience (UX).
Fortunately, you can easily fix the ERR_UNKNOWN_URL_SCHEME error. On the front end, you may need to disable Chrome extensions or simply clear the cache. Alternatively, developers can disable non-standard URLs in the app’s coding.
In this post, we’ll explain what the ERR_UNKNOWN_URL_SCHEME error is and what causes it. Then, we’ll show you how to fix it on both the front and back end. Let’s get started!
Check Out Our Video Guide To Fixing The ERR_UNKNOWN_URL_SCHEME Error:
What Is the ERR_UNKNOWN_URL_SCHEME Error?
To understand the ERR_UNKNOWN_URL_SCHEME error, let’s first discuss native apps. Put simply, a native application is installed onto a mobile device and designed for a specific operating system.
You can find native apps in the App Store or Google Play Store:
Currently, Android controls 72% of the mobile operating system market. For this reason, you may want to develop your native app for the Google Play Store. To do this, you’ll use Android Studio, which is Android’s Integrated Development Environment (IDE):
As you’re developing your app, it’s important to enable users to view embedded web browser content. Users who don’t have to navigate back and forth from a browser to your app will have a more consistent UX.
To add this feature to your app, you’ll use WebView. This special class displays web pages directly from a native app. Although the browser won’t have extensive features like a search bar or navigation controls, WebView will successfully render a web page.
However, your native app could also produce an ERR_UNKNOWN_URL_SCHEME error. In this case, the requested website has a URL scheme that the mobile device cannot recognize.
The ERR_UNKNOWN_URL_SCHEME is commonly a Chromium bug. It has been a prominent issue since Chrome 40. However, it can have a few different causes.
What Causes the ERR_UNKOWN_URL_SCHEME Error?
Although WebView can be useful in native apps, it’s only equipped to process a few different URL schemes. A URL scheme provides information about how the URL should be interpreted.
The standard URL schemes are ‘https://’ and ‘http://’. Here are some URL schemes that may cause the ERR_UNKNOWN_URL_SCHEME:
- mailto://
- whatsapp://
- file://
- telnet://
- intent://
- market://
- app://
- mail://
- buy://
If you’re an app developer, you’ll need to use specific URL coding to prevent these URL schemes from causing errors. Otherwise, users won’t be able to use WebView in your native app.
Alternatively, the ERR_UNKNOWN_URL_SCHEME error can occur when a user tries to open a redirected URL. You may also see this message after using OAuth with a custom Chrome card.
How To Fix the ERR_UNKOWN_URL_SCHEME Error (8 Methods)
For developers, the ERR_UNKNOWN_URL_SCHEME error means that your app’s WebView isn’t effectively displaying web browser pages. This will prevent users from seeing the right content.
Whether you’re a developer or a front-end user, there are a few ways to troubleshoot the issue. Here are eight fixes!
1. Disable Chrome Extensions
Many Chrome errors can be resolved by troubleshooting your browser extensions. To do this, head to More Tools > Extensions. Alternatively, you can simply search for “chrome://extensions/”:
On this page, you’ll see a list of your installed Chrome extensions. First, disable all of them using the switch in the bottom right-hand corner:
Then, check to see if the issue was resolved. If it was, you’ll know there was a problem with one of the extensions.
To figure out which extension was causing the ERR_UNKNOWN_URL_SCHEME error, reactivate them one by one. After you turn an extension on, see if the issue reappears. When it does, remove that extension completely.
2. Clear the Chrome Cache and Cookies
As you browse the Internet, your browser will save data from websites into a cache. This will ensure that your second visit processes much faster. However, this cached data can easily become corrupted.
If the first solution didn’t resolve the ERR_UNKNOWN_URL_SCHEME error, you might need to clear your browser cache. In Google Chrome, go to More Tools > Clear Browsing Data:
Then, be sure to select Cached images and files. If you’d like, you can also clear your browsing history, cookies, and other saved site data:
After this, try to reload the page you were trying to reach. If it renders without an error, you’ve fixed the problem!
3. Turn Off Hardware Acceleration
Hardware acceleration happens when a browser uses your device’s hardware to increase efficiency. In Google Chrome, your device’s Graphical Processing Unit (GPU) will start processing tasks with heavy graphics, like gaming or playing videos.
Most of the time, hardware acceleration enables Chrome to perform more complex tasks than its software can support. However, this feature can also cause lagging, freezing, and even crashes.
Therefore, you may want to disable hardware acceleration. First, open Chrome’s Settings page. Then, click on the System tab:
Lastly, use the toggle switch to turn off hardware acceleration. You’ll be prompted to relaunch Chrome with this new setting.
4. Disable Your Firewall
Another reason for the ERR_UNKNOWN_URL_SCHEME error is an incorrectly configured firewall. To see if this is the case, you can temporarily disable the firewall on your device.
For Mac users, click on the apple icon. Then, select System Settings:
From the list of tabs, hit Network. Next, find the Firewall option and toggle it off:
If you have a Windows computer, click on Start and open Settings. Then, navigate to Privacy & Security > Windows security > Firewall & network protection:
Now you’ll need to select either the Domain network, Private network, or Public network. Once you do this, find the Microsoft Defender Firewall setting and toggle it off:
You will see a security popup asking you to confirm your choice. Click on OK to save the change.
5. Create a New Chrome User Profile
If the previous methods didn’t solve the ERR_UNKNOWN_URL_SCHEME error, you could try creating a completely new Chrome user profile. Then, see if you can visit the page without any problems.
Fortunately, Google Chrome makes it easy to customize your profiles. In the upper right corner, click on your profile picture. At the bottom of the pop-up, hit Add:
This will allow you to set up a new profile. You can either sign in to an existing Chrome account or hit Continue without an account:
Before you start browsing, give the profile a name. Additionally, you might customize the color scheme:
After this, you’ll have a new Chrome profile independent of your other accounts. While using this profile, try loading the target web page. If the issue persists, it’s a good idea to contact the app developer, who will solve the problem for you.
6. Open the URL In a New Window
So far, we’ve explained how users can potentially resolve the ERR_UNKNOWN_URL_SCHEME error in a browser. If you’re a developer, you’ll need to know how to troubleshoot this problem so your app will have an error-free WebView.
An easy fix involves editing your URL href code. By including a target attribute in your app’s HTML, you’ll specify how the browser should be opened.
For example, you can add the HTML code target=”_blank”. This will open the WebView in a new window. Here’s an example:
<a href=”https://www.w3schools.com” target=”_blank”>Visit W3Schools</a>
Although this may be an effective short-term solution, it can negatively impact your app’s User Experience (UX). In web development, it’s a good idea to avoid opening new windows.
The code snippet above will remove the Back button, which could confuse users when they want to return to the previous page.
7. Add a New Intent
As an Android developer, you’ll need to use intents. Essentially, an intent describes the action you want the app to perform. If you need to fix a URL scheme error, you could consider including an intent for the content to load in an external app.
For example, you might want the ‘maps://’ URL scheme to open a user’s default maps application. Alternatively, ‘mailto://’ can open the mail app.
To add a new intent, you’ll use an IF statement. This will tell the device to open special schemes in a relevant external app. However, standard URL schemes like ‘https://’ or ‘http://’ will open normally.
Here’s how this intent would look in action:
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url == null || url.startsWith("http://") || url.startsWith("https://")) {
return false;
}
try {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
view.getContext().startActivity(intent);
return true;
} catch (Exception e) {
Log.i(TAG, "shouldOverrideUrlLoading Exception:" + e);
return true;
}
}
However, you can add a custom intent for specific external apps. If you want to send users to their installed Whatsapp, here’s how the URL override could change:
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
if (url.startsWith("whatsapp://")) {
webview.stopLoading();
try {
Intent whatsappIntent = new Intent(Intent.ACTION_SEND);
whatsappIntent.setType("text/plain");
whatsappIntent.setPackage("com.whatsapp");
whatsappIntent.putExtra(Intent.EXTRA_TEXT, webview.getUrl() + " - Shared from webview ");
startActivity(whatsappIntent);
} catch (android.content.ActivityNotFoundException ex) {
String MakeShortText = "Whatsapp has not been installed";
Toast.makeText(WebactivityTab1.this, MakeShortText, Toast.LENGTH_SHORT).show();
}
};
};
This code will enable your app to open Whatsapp on a user’s device. If it isn’t installed, there will be a toast message telling users that “Whatsapp has not been installed.”
8. Disable Non-Standard URL Schemes
Instead of using intents, you can also completely disable non-standard URL schemes. This will prevent you from using any URL schemes apart from ‘http://’ and ‘https://’.
Here’s how to implement this in HTML:
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
if (url.startsWith("http") || url.startsWith("https")) {
return true;
}else {
webview.stopLoading();
webview.goBack();
Toast.makeText(MainActivity.this, "Error: Unknown link type", Toast.LENGTH_SHORT).show();
}
return false;
}
If a user clicks on a link that uses a custom scheme, a toast message will display a message that says “Error: Unknown link type”. Since your app’s WebView won’t support custom schemes, you can completely avoid the ERR_UNKNOWN_URL_SCHEME error.
Summary
When people use your native app, they’ll want external links to open within the same application. If the requested website doesn’t have a known URL scheme, the user’s mobile device will return an ERR_UNKNOWN_URL_SCHEME error.
On the front end, you can troubleshoot this problem in Chrome browsers by turning off hardware acceleration or creating an entirely new user profile. However, in most cases, the app’s developer will need to resolve this error. As the developer, you’ll be able to fix the ERR_UNKNOWN_URL_SCHEME error by adding a new intent or opening the URL in a new window.
As you’re developing your app, you’ll need reliable and stable hosting. Our application hosting has 25 data centers and 24/7 expert chat support, so you can focus solely on development!