一、Android 7.0 的file_paths配置
1、在工程res目录下新建xml目录创建file_paths.xml文件
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<root-path name="root" path="."/>
<files-path name="files" path="." />
<cache-path name="cache" path="." />
<external-path name="external" path="." />
<external-files-path name="name" path="path" />
<external-cache-path name="name" path="path" />
</paths>
2、在AndroidManifest.xml中配置
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="com.byd.customer_services.fileprovider"
android:exported="false"
android:grantUriPermissions="true"
tools:ignore="WrongManifestParent">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
二、在android p之后
1、networkSecurityConfig配置
google在android p为了安全起见,已经明确规定禁止http协议额,但是之前很多接口都是http协议,我们一般是这样解决的:
在res目录下创建xml目录,然后随便创建一个network_security_config.xml文件,里面内容如下:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>
2、在AndroidManifest.xml文件下加上:
android:networkSecurityConfig="@xml/文件名"
<application
android:name=".BydApplication"
android:allowBackup="false"
android:hardwareAccelerated="true"
android:icon="@mipmap/byd_logo"
android:label="@string/app_name"
android:networkSecurityConfig="@xml/network_security_config"
android:roundIcon="@mipmap/byd_logo"
android:supportsRtl="false"
android:theme="@style/AppTheme">