java - 编译时没有 Ljava/nio/charset/Charset 类型的静态字段 DEF_CONTENT_CHARSET;在 Lorg/apache/http/protocol/HTTP 类中;
问题描述
使用 nexmo api 3.0+ 版本(不使用 4.0+ 因为需要 android 版本 8 api 27 )和 android 版本 6 api 23
我无法发送短信,因为它总是给出上述错误:没有 Ljava/nio/charset/Charset 类型的静态字段 DEF_CONTENT_CHARSET;在 Lorg/apache/http/protocol/HTTP 类中;
发送短信代码:
AuthMethod auth = new TokenAuthMethod(APIKey, APISecret);
NexmoClient client = new NexmoClient(auth);
TextMessage message = new TextMessage(fromRecipient, toRecipient, messageContent);
SmsSubmissionResult[] response = client.getSmsClient().submitMessage(message);
for (SmsSubmissionResult responseMessage : response) {
System.out.println(responseMessage);
}
我导入了以下内容:
implementation 'org.apache.httpcomponents:httpclient:4.5+'
implementation 'org.apache.httpcomponents:httpcore:4.4+'
但它仍在查看旧的 httpclient 而不是导入的
有没有办法强制使用导入的 http 客户端/核心库而不是旧库?
解决方案
看起来您正在尝试将 Nexmo Java Server SDK 与 Android 一起使用。这不是受支持的,因为它需要在应用程序中存储诸如机密和私钥之类的东西。
推荐的方法是在某处的服务器上使用服务器 SDK 来保护这些信息,然后使用您自己的身份验证方案通过 Android 应用程序与其通信。
推荐阅读
- c++ - 重新采购二进制文件后保存断点
- javascript - 如何使用 Javascript SDK 为 Azure 存储生成用户委托 SAS
- python - 如何在python中一起打印多个图?
- php - 在 wp_tag_cloud 参数中包含来自自定义字段的值
- python - 用户模型找不到当前用户?
- go - 将 dataType 从 bigquery.Value 更改为 string
- mysql - 如何在laravel中进行自定义订单和从大到小
- typescript - typescript 接口需要存在两个属性之一,以任何方式与参数解构兼容
- flutter - 如何将 PageView 与 Stack 一起使用?
- java - 什么时候在 milo opc ua 客户端中调用 onServiceFault?