异常:No static field INSTANCE of type Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier
Nstd opened this issue · 2 comments
Nstd commented
环境
compileSdkVersion = 30
buildToolsVersion = '30.0.3'
minSdkVersion = 21
targetSdkVersion = 29
com.aliyun.oss:aliyun-sdk-oss:3.15.1
测试机 Android 11
异常堆栈
java.lang.NoSuchFieldError: No static field INSTANCE of type Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier; in class Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier; or its superclasses (declaration of 'org.apache.http.conn.ssl.AllowAllHostnameVerifier' appears in /system/framework/framework.jar!classes4.dex)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.<clinit>(SSLConnectionSocketFactory.java:151)
at com.aliyuncs.http.clients.ApacheHttpClient.createSSLConnectionSocketFactory(ApacheHttpClient.java:120)
at com.aliyuncs.http.clients.ApacheHttpClient.initConnectionManager(ApacheHttpClient.java:134)
at com.aliyuncs.http.clients.ApacheHttpClient.init(ApacheHttpClient.java:184)
at com.aliyuncs.http.HttpClientFactory.buildClient(HttpClientFactory.java:41)
at com.aliyuncs.DefaultAcsClient.<init>(DefaultAcsClient.java:89)
at com.aliyun.oss.common.auth.STSAssumeRoleSessionCredentialsProvider.<init>(STSAssumeRoleSessionCredentialsProvider.java:52)
at com.aliyun.oss.common.auth.STSAssumeRoleSessionCredentialsProvider.<init>(STSAssumeRoleSessionCredentialsProvider.java:42)
at com.aliyun.oss.common.auth.CredentialsProviderFactory.newSTSAssumeRoleSessionCredentialsProvider(CredentialsProviderFactory.java:115)
at com.haizitong.minhang.codes.protocol.FileUploadTask.updateOSSClient(FileUploadTask.java:550)
at com.haizitong.minhang.codes.protocol.FileUploadTask.initOssSTSToken(FileUploadTask.java:562)
at com.haizitong.minhang.codes.protocol.FileUploadTask.execute(FileUploadTask.java:390)
at com.haizitong.minhang.codes.services.note.BasePublishTask.execute(BasePublishTask.java:116)
at com.haizitong.minhang.codes.services.note.BasePublishService$PublishManager.run(BasePublishService.java:286)
Code
private OSS ossClient;
private void updateOSSClient(OssSTSToken token) throws Exception {
CredentialsProvider provider = CredentialsProviderFactory.newSTSAssumeRoleSessionCredentialsProvider(
token.region, token.AccessKeyId, token.AccessKeySecret, token.roleArn
);
ossClient = new OSSClientBuilder().build(token.region, provider);
}
private static class OssSTSToken {
public String region;
public String bucket;
public String object;
public String SecurityToken;
public String AccessKeyId;
public String AccessKeySecret;
public String Expiration;
public String roleArn;
}
Nstd commented
搞错了。这是Java后台的包,应该引用Android的
IveNoDream commented
搞错了。这是Java后台的包,应该引用Android的
您好,Android使用STS临时访问凭证访问OSS的代码在文档的哪一部分啊,找了半天没看到,烦请告知,感谢