[android] WebView showing ERR_CLEARTEXT_NOT_PERMITTED although site is HTTPS

I'm starting to work on an app on Android, so I don't have much. All I have is just a WebView so far. I created the project in Android Studio, and my project got set as an Android InstantApp. I'm not sure why/how, but my guess is that I overlooked an option for it when creating the project.

I was getting an error from the WebView saying net::ERR_CLEARTEXT_NOT_PERMITTED. When I googled the error, I saw that when an app is an InstantApp, WebViews can only load sites that are HTTPS, and cannot load an HTTP site.

The purpose of this app is to be an extremely simple Flash player for only one site. This is to have better performance running a game that requires Flash. This game is at darkorbit.com, which is HTTPS.


package com.tylerr147.darkorbit;

import android.content.ComponentName;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;

public class MainActivity extends AppCompatActivity {

    protected void onCreate(Bundle savedInstanceState) {

        WebView wv = findViewById(R.id.webView1);
        wv.setWebViewClient(new CustomWebViewClient());
        WebSettings webSettings = wv.getSettings();


and CustomWebViewClient.java

package com.tylerr147.darkorbit;

import android.webkit.WebView;
import android.webkit.WebViewClient;

public class CustomWebViewClient extends WebViewClient {
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        return true;

My question: How can I disable my app as an InstantApp, or how can I get this WebView to display the site?

I feel like it's important I mention a few other details too: In the app, where it is showing the WebView, it also says "The webpage at http://darkorbit.com/" could not be loaded because: net::ERR_CLEARTEXT_NOT_PERMITTED

Notice that is says "... site at http://darkorbit.com/ ...", and not "... site at https://darkorbit.com/ ..." even though the string for the URL is hardcoded, and says "https://darkorbit.com/". Also, I am testing the app on an emulator set up as a Google Pixel 2 running Android 9.

Any help would be appreciated. Thank you.

This question is related to android android-webview

The answer is


Add the below line in your application tag:


As shown below:


UPDATE: If you have network security config such as: android:networkSecurityConfig="@xml/network_security_config"

No Need to set clear text traffic to true as shown above, instead use the below code:

<?xml version="1.0" encoding="utf-8"?>
    <domain-config cleartextTrafficPermitted="true">

    <base-config cleartextTrafficPermitted="false"/>

Set the cleartextTrafficPermitted to true

Hope it helps.

When you call "https://darkorbit.com/" your server figures that it's missing "www" so it redirects the call to "http://www.darkorbit.com/" and then to "https://www.darkorbit.com/", your WebView call is blocked at the first redirection as it's a "http" call. You can call "https://www.darkorbit.com/" instead and it will solve the issue.

Questions with android tag:

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How to implement a simple scenario the OO way My eclipse won't open, i download the bundle pack it keeps saying error log getting " (1) no such column: _id10 " error java doesn't run if structure inside of onclick listener Cannot retrieve string(s) from preferences (settings) strange error in my Animation Drawable how to put image in a bundle and pass it to another activity FragmentActivity to Fragment A failure occurred while executing com.android.build.gradle.internal.tasks Why am I seeing net::ERR_CLEARTEXT_NOT_PERMITTED errors after upgrading to Cordova Android 8? "Failed to install the following Android SDK packages as some licences have not been accepted" error Android Gradle 5.0 Update:Cause: org.jetbrains.plugins.gradle.tooling.util No Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator WebView showing ERR_CLEARTEXT_NOT_PERMITTED although site is HTTPS WARNING: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()' GoogleMaps API KEY for testing Can I use library that used android support with Androidx projects. How to allow all Network connection types HTTP and HTTPS in Android (9) Pie? Android Material and appcompat Manifest merger failed Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0 How to format DateTime in Flutter , How to get current time in flutter? How to change package name in flutter? Failed to resolve: com.android.support:appcompat-v7:28.0 What is AndroidX? Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve FirebaseInstanceIdService is deprecated installation app blocked by play protect Handling back button in Android Navigation Component Android design support library for API 28 (P) not working Failed to resolve: com.google.firebase:firebase-core:16.0.1 com.google.android.gms:play-services-measurement-base is being requested by various other libraries java.lang.NoClassDefFoundError:failed resolution of :Lorg/apache/http/ProtocolVersion Install Android App Bundle on device Conflict with dependency 'com.android.support:support-annotations' in project ':app'. Resolved versions for app (26.1.0) and test app (27.1.1) differ. How to develop Android app completely using python? Invoke-customs are only supported starting with android 0 --min-api 26 Flutter.io Android License Status Unknown How to open Android Device Monitor in latest Android Studio 3.1 Default interface methods are only supported starting with Android N How can I change the app display name build with Flutter? Error:(9, 5) error: resource android:attr/dialogCornerRadius not found error: resource android:attr/fontVariationSettings not found Flutter does not find android sdk Error - Android resource linking failed (AAPT2 27.0.3 Daemon #0) Error : Program type already present: android.support.design.widget.CoordinatorLayout$Behavior flutter run: No connected devices Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6 Still getting warning : Configuration 'compile' is obsolete and has been replaced with 'implementation' PANIC: Cannot find AVD system path. Please define ANDROID_SDK_ROOT (in windows 10)

Questions with android-webview tag:

WebView showing ERR_CLEARTEXT_NOT_PERMITTED although site is HTTPS Is `shouldOverrideUrlLoading` really deprecated? What can I use instead? Embed Youtube video inside an Android app Android WebView not loading URL Playing HTML5 video on fullscreen in android webview How to load html string in a webview? Android webview launches browser when calling loadurl Add custom headers to WebView resource requests - android Android WebView not loading an HTTPS URL How to load external webpage in WebView How to go back to previous page if back button is pressed in WebView? Android webview & localStorage Load HTML file into WebView enable/disable zoom in Android WebView How can I get onclick event on webview in android? Intercept and override HTTP requests from WebView Add a Progress Bar in WebView Android Calling JavaScript functions in WebView WebView link click open default browser Android WebView, how to handle redirects in app instead of opening a browser Loading existing .html file with android WebView Android Webview - Webpage should fit the device screen WebView and HTML5 <video> How to set the initial zoom/width for a webview How to listen for a WebView finishing loading a URL? Disable scrolling in webview? Clicking URLs opens default browser How do I get the web page contents from a WebView?