【问题标题】:when compiling No static field DEF_CONTENT_CHARSET of type Ljava/nio/charset/Charset; in class Lorg/apache/http/protocol/HTTP;编译时没有 Ljava/nio/charset/Charset 类型的静态字段 DEF_CONTENT_CHARSET;在 Lorg/apache/http/protocol/HTTP 类中;
【发布时间】:2023-03-15 10:24:01
【问题描述】:

当使用 nexmo api 3.0+ 版本(不使用 4.0+ 因为需要 android 版本 8 api 27 )和 android 版本 6 api 23 时

我无法发送短信,因为它总是给出上述错误:No static field DEF_CONTENT_CHARSET of type Ljava/nio/charset/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 而不是导入的 httpclient

有没有办法强制使用导入的 http 客户端/核心库而不是旧库?

【问题讨论】:

    标签: java android android-studio httpclient nexmo


    【解决方案1】:

    您似乎正在尝试将 Nexmo Java Server SDK 与 Android 一起使用。这不是受支持的,因为它需要在您的应用程序中存储诸如机密和私钥之类的东西。

    推荐的方法是在某处的服务器上使用服务器 SDK 来保护这些信息,然后使用您自己的身份验证方案通过 Android 应用与其通信。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-21
      • 2014-12-27
      相关资源
      最近更新 更多