Skip to content Skip to sidebar Skip to footer

No Network Security Config Specified, Using Platform Default

I'm trying to print a list of values in ListView from a webpage. I have the two permission

Solution 1:

The message you're getting isn't an error; it's just letting you know that you're not using a Network Security Configuration. If you want to add one, take a look at this page on the Android Developers website: https://developer.android.com/training/articles/security-config.html.

Solution 2:

I had the same issue and after debugging it further, I found it a thread issue. I changed onCreate method as below and it works fine. No playing Network Security Configuration file.

@OverrideprotectedvoidonCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        if (android.os.Build.VERSION.SDK_INT > 9)
        {
           StrictMode.ThreadPolicypolicy=newStrictMode.ThreadPolicy.Builder().permitAll().build();
           StrictMode.setThreadPolicy(policy);
        }
  ....
  ....
  }

Hope it helps.

Solution 3:

This is my local context solution...

I have a Docker/Lando instance providing me an API from a Lumen Restful app, local domains are not working ("https://localhost:32769", "http://localhost:32770", "http://wxyz.lndo.site", "https://wxyz.lndo.site"), however, when I check the network IP using "ifconfig" in the terminal I could access using that IP

$ ifconfig

You must add a new parameter to your AndroidManifest.xml

android:networkSecurityConfig="@xml/network_security_config"

I use this network_security_config.xml file for local debugging

<?xml version="1.0" encoding="utf-8"?><network-security-configxmlns:android="http://schemas.android.com/apk/res/android"><debug-overrides><trust-anchors><certificatessrc="user"overridePins="true"/></trust-anchors></debug-overrides></network-security-config>

I use user-permissions as well

<uses-permissionandroid:name="android.permission.INTERNET" /><uses-permissionandroid:name="android.permission.ACCESS_NETWORK_STATE" />

Solution 4:

Add this:

android:usesCleartextTraffic="true"

to your manifest application

 <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:usesCleartextTraffic="true"
        android:theme="@style/AppTheme"
    >

hope it helps

Post a Comment for "No Network Security Config Specified, Using Platform Default"