问题
穿山甲广告接入 设备上视频加载成功,但播放时黑屏或者加载图片白屏,之后跳转endcard是什么原因引起的?
如图,广告视频请求成功 缓存成功,但是一直走播放错误回调。
其实是网络安全配置导致的。
google在android p为了安全起见,已经明确规定禁止http协议额,但是之前很多接口都是http协议。
解决
在res目录下创建xml目录,然后随便创建一个.xml文件,里面内容如下:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
<domain-config>
<domain includeSubdomains="true">i.snssdk.com</domain>
<domain includeSubdomains="true">is.snssdk.com</domain>
<domain includeSubdomains="true">pangolin.snssdk.com</domain>
<domain includeSubdomains="true">extlog.snssdk.com</domain>
<domain includeSubdomains="true">sf3-ttcdn-tos.pstatp.com</domain>
<domain includeSubdomains="true">bds.snssdk.com</domain>
<domain includeSubdomains="true">dig.bdurl.net</domain>
</domain-config>
</network-security-config>
然后在AndroidManifest.xml文件下加上:
android:networkSecurityConfig="@xml/文件名"
<application
android:name=".base.BaseApplication"
android:allowBackup="true"
android:icon="@mipmap/app_logo"
android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
android:roundIcon="@mipmap/app_logo"
android:supportsRtl="true"
android:networkSecurityConfig="@xml/network_security_config"
>