当前位置: 首页 > 知识库问答 >
问题:

ews-java-api上的NoSuchMethodError

黄君博
2023-03-14
03-25 15:37:23.551    1875-1875/com.example.XXXXX.test E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.XXXXXX.test, PID: 1875
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/client/protocol/HttpClientContext;
        at microsoft.exchange.webservices.data.ExchangeServiceBase.initializeHttpContext(ExchangeServiceBase.java:211)
        at microsoft.exchange.webservices.data.ExchangeServiceBase.setUseDefaultCredentials(ExchangeServiceBase.java:628)
        at microsoft.exchange.webservices.data.ExchangeServiceBase.<init>(ExchangeServiceBase.java:158)
        at microsoft.exchange.webservices.data.ExchangeServiceBase.<init>(ExchangeServiceBase.java:164)
        at microsoft.exchange.webservices.data.ExchangeService.<init>(ExchangeService.java:3663)
        at com.example.XXXXXX.test.MainActivity.onCreate(MainActivity.java:25)
        at android.app.Activity.performCreate(Activity.java:5933)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
        at android.app.ActivityThread.access$800(ActivityThread.java:144)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:135)
        at android.app.ActivityThread.main(ActivityThread.java:5221)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
 Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.http.client.protocol.HttpClientContext" on path: DexPathList[[zip file "/data/app/com.example.XXXXXXX.test-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at      microsoft.exchange.webservices.data.ExchangeServiceBase.initializeHttpContext(ExchangeServiceBase.java:211)
 at microsoft.exchange.webservices.data.ExchangeServiceBase.setUseDefaultCredentials(ExchangeServiceBase.java:628)
at microsoft.exchange.webservices.data.ExchangeServiceBase.<init>(ExchangeServiceBase.java:158)
at microsoft.exchange.webservices.data.ExchangeServiceBase.<init>(ExchangeServiceBase.java:164)
at microsoft.exchange.webservices.data.ExchangeService.<init>(ExchangeService.java:3663)
at com.example.XXXXXX.test.MainActivity.onCreate(MainActivity.java:25)
at android.app.Activity.performCreate(Activity.java:5933)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Suppressed: java.lang.ClassNotFoundException: org.apache.http.client.protocol.HttpClientContext
        at java.lang.Class.classForName(Native Method)
        at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
        at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
        ... 20 more
 Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

这些是build中的依赖项。gradle:

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:19.0.0'
//compile 'org.apache.httpcomponents:httpclient:4.4'
//compile 'org.apache.httpcomponents:httpcore:4.3.3'
//compile 'commons-logging:commons-logging:1.2'
//compile 'joda-time:joda-time:2.7'
}

下面是我目前正在测试的onCreate:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    ExchangeService service = new ExchangeService(); // this is where the error is hitting
    ExchangeCredentials credentials = new WebCredentials("user", "pw");
    service.setCredentials(credentials);

    try {
        service.setUrl(new URI("uri"));
    } catch (URISyntaxException e) {
        e.printStackTrace();
    }

    EmailMessage msg= null;
    try {
        msg = new EmailMessage(service);
        msg.setSubject("Hello world!");
        msg.setBody(MessageBody.getMessageBodyFromText("Sent using the EWS Java API."));
        msg.getToRecipients().add("email");
        msg.send();
    } catch (Exception e) {
        e.printStackTrace();
    }


}

共有1个答案

公孙琛
2023-03-14

尝试添加

编译'org.apache.httpcomponents:httpclient:4.4'

在build.gradle文件中

 类似资料:
  • ews-java-api 是用来访问 Exchange Web 服务的 Java 客户端库,API 支持 Office 365 Exchange Online。

  • We have a Daemon application that uses the EWS API to access office365/Exchange server with basic authentication.I am trying to implement the Oauth2.There are a lot of documents.However, they are ofte

  • 我在Office365租户中有几个用户帐户。其中两个几乎相同(设置相似但联系信息和姓名不同)。我尝试使用GetFolder操作从包含next Body的EWS API获取用户邮箱中的信息(如所有文件夹和项目):

  • EWS

    我是在VB. Net中编写EWS的新手。我的目标是从到达指定收件箱的邮件中提取附件并将它们保存到指定的文件夹中。我测试了一些代码,这些代码在针对我的域/Exchange帐户使用时似乎效果很好。 然后,我创建了一个新帐户并尝试使用相同的代码。它开始产生错误: 请求失败。远程服务器返回错误:(401)未授权。 到目前为止,代码非常基本: 错误是由最后一行产生的。 到目前为止,我已经比较了工作用户和新创

  • 我正在寻找通过ews api获取所有邮箱列表的方法。 是否有任何方法调用,Powershell中的Get-Mailbox cmd,可以获取EWS API中Exchange Server / Office 365中所有邮箱的列表?

  • 我是EWS管理API的新手。我想知道是否有任何方法可以将使用EWS API的exchange日历导出到ics文件中。我搜索并找到了创建和检索日历项的方法,但找不到导出日历的方法。非常感谢任何帮助