title: Using Network Security Config from resource network_security_config debugBuild: true
body: <p>I was trying out this code, which should show the html code of certain website in the Logcat.
  But I was only getting
  <code> Using Network Security Config from resource network_security_config debugBuild: true</code>
  and
  <code>java.net.UnknownHostException: Unable to resolve host &quot;www.google.co.in&quot;: No address associated with hostname</code></p>
  <p>My internet connection is active. I was following a android tutorial, and that guy did the same and got the result.(He was using old version of android studio</p>
  <p><strong>java code</strong></p>
  <pre><code>package com.example.newapp;
  
  import androidx.appcompat.app.AppCompatActivity;
  
  import android.os.AsyncTask;
  import android.os.Bundle;
  import android.util.Log;
  
  import java.io.InputStream;
  import java.io.InputStreamReader;
  import java.net.HttpURLConnection;
  import java.net.URL;
  import java.util.concurrent.ExecutionException;
  
  public class MainActivity extends AppCompatActivity {
  
      public static class DownloadTask extends AsyncTask&lt;String, Void, String&gt;
      {
  
          @Override
          protected String doInBackground(String... urls) {
              String result= &quot;&quot;;
              URL url;
              HttpURLConnection urlConnection= null;
              try{
                  url= new URL(urls[0]);
  
                  urlConnection=(HttpURLConnection) url.openConnection();
                  InputStream in = urlConnection.getInputStream();
                  InputStreamReader reader= new InputStreamReader(in);
                  int data = reader.read();
  
                  while (data != -1)
                  {
                      char current = (char)data;
                      result+= current;
                      data= reader.read();
                  }
                  return result;
              }
              catch (Exception e)
              {
                  e.printStackTrace();
                  return &quot;failed&quot;;
              }
  
          }
      }
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          DownloadTask task= new DownloadTask();
          String result = null;
          try {
              result= task.execute(&quot;https://www.google.co.in//&quot;).get();
          } catch (ExecutionException e) {
              e.printStackTrace();
          } catch (InterruptedException e) {
              e.printStackTrace();
          }
  
          Log.i(&quot;Contents of URL&quot; ,result);
      }
  }
  </code></pre>
  <p><strong>AndroidManifest.xml</strong></p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      package=&quot;com.example.newapp&quot;&gt;
  
      &lt;uses-permission android:name=&quot;android.permission.INTERNET&quot; /&gt;
  
      &lt;application
          android:allowBackup=&quot;true&quot;
          android:icon=&quot;@mipmap/ic_launcher&quot;
          android:label=&quot;@string/app_name&quot;
          android:roundIcon=&quot;@mipmap/ic_launcher_round&quot;
          android:supportsRtl=&quot;true&quot;
          android:theme=&quot;@style/AppTheme&quot;
          android:usesCleartextTraffic=&quot;true&quot;
          android:networkSecurityConfig=&quot;@xml/network_security_config&quot; &gt;
          &lt;activity android:name=&quot;.MainActivity&quot;&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt;
  
                  &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  <p><strong>network_security_config.xml</strong></p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;network-security-config&gt;
      &lt;base-config cleartextTrafficPermitted=&quot;true&quot; /&gt;
  &lt;/network-security-config&gt;
  </code></pre>