在 Android 9.0 的手机上,上传文件到阿里云 OSS 上,不论请求是否成功,均没有回调。html
而在 9.0 如下的手机中,尝试均没有问题。android
上传调用方式以下:git
OSSClient oss = new OSSClient(context, endpoint, credentialProvider, conf);
PutObjectResult putResult = oss.putObject(put);
⬇️
这一步后报错。
oss 上传的地址: http://oss-cn-hangzhou.aliyuncs.com
复制代码
报错内容:github
Failed resolution of: Lorg/apache/commons/codec/binary/Base64;
复制代码
更改 AndroidManifest 的 application 标签下的配置。apache
添加 networkSecurityConfig(网络安全配置)。api
android:networkSecurityConfig="@xml/network_security_config"
复制代码
network_security_config 文件内容以下:安全
<?xml version="1.0" encoding="utf-8"?>
<network-security-config xmlns:tools="http://schemas.android.com/tools">
<base-config cleartextTrafficPermitted="true"/>
</network-security-config>
复制代码
其余标签属性参考:网络安全性配置bash
兼容后,再次尝试,依然是报错。网络
api 'com.aliyun.dpa:oss-android-sdk:+'
,如今最新版为 2.9.2。http://oss-cn-hangzhou.aliyuncs.com
再次尝试成功。app
这个错误耗费了我几乎一下午的时间,在此记录一下,以防遗忘。