我想爲我的android應用程序使用EWS-Java-API。 應用程序需要登錄才能以編程方式訪問Microsoft Exchange Server(例如日曆會議,電子郵件,會議室等)。EWS-Java-API - EmailMessage.send進入java.lang.NullPointerException:format == null
此時幾乎整個問題都被編輯了,以防萬一以顯示目前的情況。
我試圖讓連接到Exchange版本15.0.11與URL( 「HTTPS://yourserver/EWS/Exchange.asmx」)
的gradle構建文件:
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
useLibrary 'org.apache.http.legacy'
defaultConfig {
minSdkVersion 18
targetSdkVersion 22
versionCode 1
versionName "1.0"
multiDexEnabled true
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/license.txt'
exclude 'META-INF/LGPL2.1'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/notice.txt'
} [...] }
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:design:23.3.0'
compile 'com.google.android.gms:play-services:6.5.87'
compile 'org.altbeacon:android-beacon-library:2.7.1'
compile 'org.greenrobot:eventbus:3.0.0'
compile files('libs/jcifs-1.3.15.jar')
compile files('libs/commons-logging-1.1.1.jar')
compile files('libs/commons-codec-1.4.jar')
compile files('libs/commons-httpclient-3.1.jar')
compile 'com.microsoft.ews-java-api:ews-java-api:2.0' }
這會導致這個錯誤信息
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/client/protocol/HttpClientContext;
線:
ExchangeService service = new ExchangeService();
此時我測試了這個ews庫「github.com/faisons/EWS-For-Android」。
3210這幾乎工作。 Iam能夠啓動應用程序並設置ExchangeService。現在
Thread thread = new Thread(new Runnable()
{
@Override
public void run()
{
try
{
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
ExchangeCredentials credentials = new WebCredentials(myuser, mypw);
service.setCredentials(credentials);
service.setUrl(new URI("https://exchmail.yourserver.com/EWS/Exchange.asmx"));
EmailMessage message = new EmailMessage(service);
EmailAddress from = new EmailAddress(myemail);
message.setSender(from);
message.getToRecipients().add(anotherEmail);
message.setSubject("Much wow - such message");
MessageBody messageBody = new MessageBody();
messageBody.setText("text here");
message.setBody(messageBody);
message.send();
}
catch (Exception e)
{
Log.e(TAG, "message", e);
}
}
});
thread.start();
的錯誤是:
java.lang.NullPointerException: format == null
at java.lang.String.format(String.java:1799)
at java.lang.String.format(String.java:1777)
at java.lang.String.format(String.java:1799)
at microsoft.exchange.webservices.data.ServiceRequestBase.getEwsHttpWebResponse(ServiceRequestBase.java:936)
at microsoft.exchange.webservices.data.ServiceRequestBase.validateAndEmitRequest(ServiceRequestBase.java:821)
at microsoft.exchange.webservices.data.SimpleServiceRequestBase.internalExecute(SimpleServiceRequestBase.java:46)
at microsoft.exchange.webservices.data.MultiResponseServiceRequest.execute(MultiResponseServiceRequest.java:143)
at microsoft.exchange.webservices.data.ExchangeService.internalCreateItems(ExchangeService.java:463)
at microsoft.exchange.webservices.data.ExchangeService.createItem(ExchangeService.java:534)
at microsoft.exchange.webservices.data.Item.internalCreate(Item.java:215)
at microsoft.exchange.webservices.data.EmailMessage.internalSend(EmailMessage.java:125)
蔭困惑如何獲得API的使用。如果有人知道另一種方式獲得訪問任何提示是值得歡迎的!
我得到了」java .lang.NoClassDefFoundError:無法解析:Ljava/applet/Applet「,當我調用AutodiscoverService.getUserSettings時,已經在https://github.com/alipov/ews-android-api/issues/3上有記錄。你是如何解決這個問題的? – NotAgain