如何为 API 小于 24 添加 Android 网络安全配置

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

Facebook Audience Network 指出。

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.

现在,如果我尝试在我的 AndroidManifest 中添加这一行 android:networkSecurityConfig="@xml/network_security_config",我会收到警告,属性 networkSecurityConfig 在 API 24 及更高版本中使用,因为我的应用程序支持 [=23] =]minSdkVersion 15。

我应该如何添加 android:networkSecurityConfig 才不会影响 API 小于 24

默认情况下它是这样工作的。较旧的设备无法识别 android:networkSecurityConfig,因为它在 API 24 级(Android 7.0)之前不存在。