Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add Android Network Security Config for API less than 24

Tags:

Facebook Audience Network states that.

In the Audience Network Android SDK, we use 127.0.0.1 (localhost) as a caching proxy to cache media files in the SDK. Since Android P, cleartext traffic (unencrypted HTTP) will be blocked by default, which will affect the functionality of media caching of the SDK and could affect user experience and ads revenue.

Now if I try to add this line android:networkSecurityConfig="@xml/network_security_config" in my AndroidManifest I am getting warning that attribute networkSecurityConfig is used in API 24 and higher as my app supports minSdkVersion 15 .

How should I add the android:networkSecurityConfig so that it won't be impacting API less than 24

like image 303
Zeeshan Avatar asked Oct 07 '18 17:10

Zeeshan


People also ask

How do I configure network security configuration on Android?

The Network Security Configuration is available on Android 7.0 (API level 24) and higher. Create a new xml resource file with the name network_security_config.xml. In the Android Project Panel on the left hand side, right click on res, then select New > Android resource file. Set the following options and click OK.

What is the default configuration for Android apps targeting API levels?

The default configuration for apps targeting Android 7.0 (API level 24) to Android 8.1 (API level 27) is as follows: The default configuration for apps targeting Android 6.0 (API level 23) and lower is as follows: ... Configuration used for connections to specific destinations, as defined by the domain elements.

Why does API level 15-23 ignore Android network security config?

@ZayidMohammed: API Level 15-23 will ignore android:networkSecurityConfig, since that did not exist when those versions of Android were released.

How to debug app network connections in Android?

Debug app network connections Another option offered in Android Network Security Configuration is debug-overrides. This feature allows you to have settings in the Network Security Config that will only be usable when android:debuggable is set to true.


1 Answers

It works that way by default. Older devices will not recognize android:networkSecurityConfig, since it did not exist prior to API Level 24 (Android 7.0).

like image 122
CommonsWare Avatar answered Oct 14 '22 16:10

CommonsWare