title: Cordova 5.1.1 "There was a network error" message in onReceivedError method when I call network url from Cordova Android webview
body: <p>I am using Cordova 5.1.1. I want to call network URL from CordovaWebview in android. My Android OS version is 4.4.2. Here is my code from Android Side.</p>
  
  <p><strong><em>Android</em></strong></p>
  
  <p><strong>content_main.xml file:-</strong></p>
  
  
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent"
      android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      android:paddingBottom="@dimen/activity_vertical_margin"
      app:layout_behavior="@string/appbar_scrolling_view_behavior"
      tools:showIn="@layout/activity_main" tools:context=".MainActivity"&gt;
  
      &lt;org.apache.cordova.engine.SystemWebView
          android:id="@+id/cordovaWebView"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>Here is my java file where i have initialized WebView and call a network url.</p>
  
  <p><strong>MainActivity.java:-</strong></p>
  
  <pre><code>package com.andapp.kushpatel.cordova5_file_chooser;
  
  import android.app.Activity;
  import android.app.ProgressDialog;
  import android.content.Intent;
  import android.graphics.Bitmap;
  import android.os.Bundle;
  import android.support.design.widget.FloatingActionButton;
  import android.support.design.widget.Snackbar;
  import android.support.v7.app.AppCompatActivity;
  import android.support.v7.widget.Toolbar;
  import android.util.Log;
  import android.view.View;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.webkit.WebChromeClient;
  import android.webkit.WebView;
  import android.webkit.WebViewClient;
  
  import org.apache.cordova.ConfigXmlParser;
  import org.apache.cordova.CordovaInterface;
  import org.apache.cordova.CordovaInterfaceImpl;
  import org.apache.cordova.CordovaPlugin;
  import org.apache.cordova.CordovaWebView;
  import org.apache.cordova.CordovaWebViewEngine;
  import org.apache.cordova.CordovaWebViewImpl;
  import org.apache.cordova.engine.SystemWebView;
  import org.apache.cordova.engine.SystemWebViewEngine;
  
  import java.util.concurrent.ArrayBlockingQueue;
  import java.util.concurrent.ExecutorService;
  import java.util.concurrent.Executors;
  
  public class MainActivity extends AppCompatActivity implements CordovaInterface{
  
  
      private static String TAG = MainActivity.class.getSimpleName();
      private CordovaWebView cordovaWebView;
      public static final String START_URL = "http://localhost:8080/GCM_Project/";
  
      CordovaPlugin activityResultCallback;
      private Object activityResultKeepRunning;
      private Object keepRunning;
      private final ExecutorService threadPool = Executors.newCachedThreadPool();
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.content_main);
  
  
          //Set up the webview
              ConfigXmlParser parser = new ConfigXmlParser();
              parser.parse(this);
  
          SystemWebView syswebView = (SystemWebView) findViewById(R.id.cordovaWebView);
          cordovaWebView = new CordovaWebViewImpl(new SystemWebViewEngine(syswebView));
          cordovaWebView.init(this, parser.getPluginEntries(), parser.getPreferences());
          cordovaWebView.loadUrl(START_URL);
  
  
  
      }
  
      @Override
      public void startActivityForResult(CordovaPlugin command, Intent intent, int requestCode) {
          this.activityResultCallback = command;
          this.activityResultKeepRunning = this.keepRunning;
  
          // If multitasking turned on, then disable it for activities that return results
          if (command != null) {
              this.keepRunning = false;
          }
  
          // Start activity
          super.startActivityForResult(intent, requestCode);
      }
  
      @Override
      public void setActivityResultCallback(CordovaPlugin plugin) {
          this.activityResultCallback = plugin;
      }
  
      @Override
      public Activity getActivity() {
          return this;
      }
  
      @Override
      public Object onMessage(String s, Object o) {
          return null;
      }
  
      @Override
      public ExecutorService getThreadPool() {
          return threadPool;
      }
  
      @Override
      public void requestPermission(CordovaPlugin cordovaPlugin, int i, String s) {
  
      }
  
      @Override
      public void requestPermissions(CordovaPlugin cordovaPlugin, int i, String[] strings) {
  
      }
  
      @Override
      public boolean hasPermission(String s) {
          return false;
      }
  }
  </code></pre>
  
  <p>Here is my config file where I have used two Cordova plugins.</p>
  
  <p><strong>config.xml</strong></p>
  
  <pre><code>&lt;widget id="io.cordova.helloCordova" version="2.0.0" xmlns="http://www.w3.org/ns/widgets"&gt;
      &lt;name&gt;Hello Cordova&lt;/name&gt;
      &lt;description&gt;
          A sample Apache Cordova application that responds to the deviceready event.
      &lt;/description&gt;
      &lt;author email="dev@cordova.apache.org" href="http://cordova.io"&gt;
          Apache Cordova Team
      &lt;/author&gt;
      &lt;access origin="http://*/*"/&gt;
      &lt;access origin="https://*/*"/&gt;
      &lt;access origin="*.apache.org" /&gt;
      &lt;access origin="http://*.google.com/*" /&gt;
      &lt;access origin="https://*.google.com/*" /&gt;
      &lt;access origin="https://*.googleapis.com/*" /&gt;
      &lt;access origin="https://*.gstatic.com/*" /&gt;
      &lt;access origin="tel:*" launch-external="yes"/&gt;
      &lt;access origin="geo:*" launch-external="yes"/&gt;
      &lt;access origin="mailto:*" launch-external="yes"/&gt;
      &lt;access origin="sms:*" launch-external="yes"/&gt;
      &lt;access origin="market:*" launch-external="yes"/&gt;
      &lt;content src="index.html" /&gt;
  
      &lt;allow-navigation href="http://*/*" /&gt;
      &lt;allow-navigation href="https://*/*" /&gt;
  
      &lt;preference name="loglevel" value="DEBUG" /&gt;
  
      &lt;feature name="FileChooser"&gt;
          &lt;param name="android-package" value="com.andapp.kushpatel.cordova5_file_chooser.FileChooser" /&gt;
      &lt;/feature&gt;
  
      &lt;feature name="WhitelistPlugin"&gt;
          &lt;param name="android-package" value="com.andapp.kushpatel.cordova5_file_chooser.WhitelistPlugin" /&gt;
      &lt;/feature&gt;
  
      &lt;preference name="loadUrlTimeoutValue" value="300000" /&gt;
  &lt;/widget&gt;
  </code></pre>
  
  <p>At server side there is a html file. In that html file I have used meta tag for whiteList plugin.</p>
  
  <pre><code> &lt;meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'"/&gt;
  </code></pre>
  
  <p>Now when I call that never nothing displays in webview and in log i am getting <strong>"There was a network error"</strong> error.</p>
  
  <p>I have refered below links for described code.
  <a href="https://cordova.apache.org/docs/en/6.x/reference/cordova-plugin-whitelist/" rel="nofollow noreferrer">https://cordova.apache.org/docs/en/6.x/reference/cordova-plugin-whitelist/</a></p>
  
  <p><a href="https://stackoverflow.com/questions/29614858/how-to-configure-cordova-android-4-0-with-white-list">How to configure Cordova-android 4.0 with white-list</a></p>
  
  <p><a href="https://stackoverflow.com/questions/30212306/no-content-security-policy-meta-tag-found-error-in-my-phonegap-application">&quot;No Content-Security-Policy meta tag found.&quot; error in my phonegap application</a></p>