使用Android上的EWS的Java API问题 [英] Problems using the EWS Java API on Android

查看:953
本文介绍了使用Android上的EWS的Java API问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用EWS的Java API V1.1.5(http://archive.msdn.microsoft.com/ewsjavaapi)在Android应用程序,并遇到了一些问题。 我下载的源代码,并随后提供给编译Eclipse中的EWS的Java API的说明。在这些指令,你被告知下载 添加以下pre-requiste jar文件的依赖关系:

I am trying to use the EWS Java API v1.1.5 (http://archive.msdn.microsoft.com/ewsjavaapi) in an Android application, and have run into a number of issues. I downloaded the source, and followed the instructions provided to compile the EWS Java API in Eclipse. In those instructions you are told to download and add the following pre-requiste jar file dependencies:

  • commons- codeC-1.4.jar
  • 公地的HttpClient-3.1.jar
  • 共享记录-1.1.1.jar
  • JCIFS-1.3.15.jar

我照做了,随后与产生了以下jar文件编译指令:

I did this, and followed the build instructions with produced the following jar files:

  • EWSAPI-1.1.0.jar
  • EWSAPIWithJars-1.1.0

接下来,我建立了一个全新的Andr​​oid应用程序,添加适当的权限清单,然后添加下列源的主要活动的OnCreate:

Next, I built a brand new Android application, added the appropriate permissions to the manifest, and then added the following source to the primary activity's OnCreate:

ExchangeService service = new ExchangeService();
ExchangeCredentials credentials = new WebCredentials("emailaddress", "password");       
service.setCredentials(credentials);

try
{
    service.autodiscoverUrl("emailaddress", this);
}
catch (Exception e)
{       
    e.printStackTrace();
}

我第一次尝试运行此应用程序与EWSAPI-1.1.0.jar文件作为依赖。当我这样做,我得到以下致命错误:

I first tried running this application with the EWSAPI-1.1.0.jar file as a dependency. When I did that, I obtained the following fatal error:

未捕获的处理程序:螺纹主力退出,由于未捕获的异常   java.lang.NoClassDefFoundError的:   org.apache.commons.httpclient.MultiThreadedHttpConnectionManager在   microsoft.exchange.webservices.data.ExchangeServiceBase。(未知   源)以   microsoft.exchange.webservices.data.ExchangeServiceBase。(未知   源)以   microsoft.exchange.webservices.data.ExchangeService。(未知   源)以   com.meshin.exchange.ExchangeDiscoveryActivity.onCreate(ExchangeDiscoveryActivity.java:40)

Uncaught handler: thread main exiting due to uncaught exception java.lang.NoClassDefFoundError: org.apache.commons.httpclient.MultiThreadedHttpConnectionManager at microsoft.exchange.webservices.data.ExchangeServiceBase.(Unknown Source) at microsoft.exchange.webservices.data.ExchangeServiceBase.(Unknown Source) at microsoft.exchange.webservices.data.ExchangeService.(Unknown Source) at com.meshin.exchange.ExchangeDiscoveryActivity.onCreate(ExchangeDiscoveryActivity.java:40)

从我研究过,好像正在生成该错误,因为Android自带与Apache的HttpClient 4.0,它不会出现 有MultiThreadedHttpConnectionManager类了。

From what I've researched, it seems like this error is being generated because Android comes with the Apache HttpClient 4.0, which doesn't appear to have the MultiThreadedHttpConnectionManager class anymore.

如果我不是删除EWSAPI-1.1.0.jar,而是使用EWSAPIWithJARS-1.1.0.jar文件作为依赖,我得到以下错误:

If I instead remove the EWSAPI-1.1.0.jar, and instead use the EWSAPIWithJARS-1.1.0.jar file as a dependency, I get the following error:

VFY:无法解析静态方法908:Ljavax / XML /流/ XMLOutputFactory;   的newInstance()Ljavax / XML /流/ XMLOutputFactory;   VFY:在L静code 0x0008-006a   微软/交换/ web服务/数据/ EwsUtilities; .formatLogMessage   (Ljava /朗/字符串; Ljava /朗/字符串;)Ljava /朗/字符串;   VFY:找不到签名中引用的类(Ljavax / XML /流/ XMLStreamWriter;)

VFY: unable to resolve static method 908: Ljavax/xml/stream/XMLOutputFactory; newInstance()Ljavax/xml/stream/XMLOutputFactory; VFY: dead code 0x0008-006a in L microsoft/exchange/webservices/data/EwsUtilities;.formatLogMessage (Ljava/lang/String;Ljava/lang/String;) Ljava/lang/String; VFY: unable to find class referenced in signature (Ljavax/xml/stream/XMLStreamWriter;)

然后最终...

致命异常:主要java.lang.VerifyError:   microsoft.exchange.webservices.data.AutodiscoverService在   microsoft.exchange.webservices.data.ExchangeService.getAutodiscoverUrl(未知   源)以   microsoft.exchange.webservices.data.ExchangeService.autodiscoverUrl(未知   源)以   com.meshin.exchange.ExchangeDiscoveryActivity.onCreate(ExchangeDiscoveryActivity.java:41)

FATAL EXCEPTION: main java.lang.VerifyError: microsoft.exchange.webservices.data.AutodiscoverService at microsoft.exchange.webservices.data.ExchangeService.getAutodiscoverUrl(Unknown Source) at microsoft.exchange.webservices.data.ExchangeService.autodiscoverUrl(Unknown Source) at com.meshin.exchange.ExchangeDiscoveryActivity.onCreate(ExchangeDiscoveryActivity.java:41)

我假设,因为我现在包括的HttpClient 3.1罐子,它有冲突的的HttpClient 4.0的jar包含了Android库。

I am assuming because now I am including the HttpClient 3.1 jar and it is conflicting with the HttpClient 4.0 jar included with the Android libraries.

我的问题是,如果有一种方法对我来说,使用EWS的Java API在Android项目,而无需重新编写它的哪个部分参考 HttpClient的这不再4.0 3.1特有的东西。

My question is if there is a way for me to use the EWS Java API in an Android project without having to re-write the parts of it which reference HttpClient 3.1-specific things which are no longer in 4.0.

推荐答案

您可以通过执行以下步骤使用微软的EWS API为Android,

You can use microsoft's EWS api for android by doing the following steps,

  1. 下载源$ C ​​$ C提供的网址, http://archive.msdn.microsoft.com/ewsjavaapi EWSJavaAPI_1.1.5.zip

  1. download the source code available in the URL, http://archive.msdn.microsoft.com/ewsjavaapi EWSJavaAPI_1.1.5.zip

请更改上面的API在Eclipse工作的JDK 1.4等清除覆盖批注等

Make the changes to above api to work for JDK 1.4 in eclipse like remove override annotations e.t.c

下载源$ C ​​$的javax的角*包在下面的网址提供, http://www.java2s.com/$c$c/JarDownload/jsr173/jsr173_1.0_src.jar.zip

Download source code of javax.* package available in below URL, http://www.java2s.com/Code/JarDownload/jsr173/jsr173_1.0_src.jar.zip

下载源$ C ​​$ STAX的API c。在下面的网址提供, HTTP://dist.$c$ chaus.org/stax/distributions/stax-src-1.2.0.zip

Download source code of stax api available in below URL, http://dist.codehaus.org/stax/distributions/stax-src-1.2.0.zip

请单Java项目下的所有源代码在eclipse

Keep all the sources under the single java project in eclipse

打开项目资源管理器,并选择其中打头的包的的javax ,并改名为您的公司名称,例如: COM 注意:的Eclipse将要求所有的命名上下文将发生变化,然后单击确定

Open the project explorer and select the package which are starts with "javax" and rename to your company name eg: com. Note: Eclipse will ask for all the naming contexts will change then click OK.

导出所有的Java源代码,以一个单一的jar文件。

Export all the java sources to one single jar file.

然后你很好的去使用Android应用程序的jar指出,没有任何问题。

Then You good to go to use the jar in Android application with out any problems.

我用上述同样的方式解释和它的工作在Android应用程序100%完美。

I used the same way explained above and it worked in android application 100% perfectly.

这篇关于使用Android上的EWS的Java API问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆