3

자바에서 교환 웹 서비스를 이미 시도하고 있습니다. 잘 돌아갑니다. 그것은 이메일을 보내거나 이메일을 올바르게 받았습니다.안드로이드 - 아파치 공유 라이브러리 및 Exchange 웹 서비스 관리 API

내 자바 코드는 다음과 같습니다

public static void main(String[] args) { 
    try { 
     Locale.setDefault(Locale.ENGLISH); 
     ExchangeService service = new ExchangeService(); 
     WebCredentials webCredentials = new WebCredentials("[email protected]", "asdasdasd"); 
     URI url = new URI("https://asdasd802.outlook.com/ews/Exchange.asmx"); 
     service.setCredentials(webCredentials); 
     service.setUrl(url); 

     System.out.println(service.getRequestedServerVersion()); 

     msg.setSubject("Hello world!"); 
     msg.setBody(MessageBody.getMessageBodyFromText("Sent using the EWS Managed API.")); 
     msg.getToRecipients().add("[email protected]"); 
     msg.send(); 

    } catch (Exception ex) { 
     ex.printStackTrace(); 
     //System.out.println(ex.toString()); 
    } 

} 

이 코드와 안드로이드에서 이것을 시도 할 때 :

public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main_layout); 
    Button b = (Button) findViewById(R.id.button1); 
    b.setOnClickListener(new OnClickListener() { 

     @Override 
     public void onClick(View v) { 

      Locale.setDefault(Locale.ENGLISH); 
      try { 
       ExchangeService service = new ExchangeService(); 
       WebCredentials webCredentials = new WebCredentials(
         "[email protected]", 
         "asdasd"); 
       URI url = new URI("https://asdasd.outlook.com/ews/Exchange.asmx"); 
       service.setCredentials(webCredentials); 
       service.setUrl(url); 

       EmailMessage msg= new EmailMessage(service); 
       msg.setSubject("Hello world!"); 
       msg.setBody(MessageBody.getMessageBodyFromText 
          ("Sent using the EWS Managed API.")); 
       msg.getToRecipients().add("[email protected]"); 
       msg.send(); 

      } catch (Exception ex) { 
       //ex.printStackTrace(); 
       System.out.println(ex.toString()); 
      } 
     } 
    }); 
} 

내가 약간의 오차가 얻을, 버튼을 클릭 할 때.

 
[2011-12-15 17:06:25 - MobileApplication1] Dx warning: Ignoring InnerClasses attribute for an anonymous inner class 
(org.apache.commons.httpclient.HttpMethodBase$1) that doesn't come with an 
associated EnclosingMethod attribute. This class was probably produced by a 
compiler that did not target the modern .class file format. The recommended 
solution is to recompile the class from source, using an up-to-date compiler 
and without specifying any "-target" type options. The consequence of ignoring 
this warning is that reflective operations on this class will incorrectly 
indicate that it is *not* an inner class. 
[2011-12-15 17:06:25 - MobileApplication1] Dx warning: Ignoring InnerClasses attribute for an anonymous inner class 
(org.apache.commons.httpclient.protocol.ControllerThreadSocketFactory$1) that doesn't come with an 
associated EnclosingMethod attribute. This class was probably produced by a 
compiler that did not target the modern .class file format. The recommended 
solution is to recompile the class from source, using an up-to-date compiler 
and without specifying any "-target" type options. The consequence of ignoring 
this warning is that reflective operations on this class will incorrectly 
indicate that it is *not* an inner class. 
[2011-12-15 17:06:25 - MobileApplication1] Dx warning: Ignoring InnerClasses attribute for an anonymous inner class 
(org.apache.commons.logging.impl.LogFactoryImpl$1) that doesn't come with an 
associated EnclosingMethod attribute. This class was probably produced by a 
compiler that did not target the modern .class file format. The recommended 
solution is to recompile the class from source, using an up-to-date compiler 
and without specifying any "-target" type options. The consequence of ignoring 
this warning is that reflective operations on this class will incorrectly 
indicate that it is *not* an inner class. 
[2011-12-15 17:06:25 - MobileApplication1] Dx warning: Ignoring InnerClasses attribute for an anonymous inner class 
(org.apache.commons.logging.impl.LogFactoryImpl$2) that doesn't come with an 
associated EnclosingMethod attribute. This class was probably produced by a 
compiler that did not target the modern .class file format. The recommended 
solution is to recompile the class from source, using an up-to-date compiler 
and without specifying any "-target" type options. The consequence of ignoring 
this warning is that reflective operations on this class will incorrectly 
indicate that it is *not* an inner class. 
[2011-12-15 17:06:25 - MobileApplication1] Dx warning: Ignoring InnerClasses attribute for an anonymous inner class 
(org.apache.commons.logging.impl.LogFactoryImpl$3) that doesn't come with an 
associated EnclosingMethod attribute. This class was probably produced by a 
compiler that did not target the modern .class file format. The recommended 
solution is to recompile the class from source, using an up-to-date compiler 
and without specifying any "-target" type options. The consequence of ignoring 
this warning is that reflective operations on this class will incorrectly 
indicate that it is *not* an inner class. 
[2011-12-15 17:06:25 - MobileApplication1] Dx warning: Ignoring InnerClasses attribute for an anonymous inner class 
(org.apache.commons.logging.impl.SimpleLog$1) that doesn't come with an 
associated EnclosingMethod attribute. This class was probably produced by a 
compiler that did not target the modern .class file format. The recommended 
solution is to recompile the class from source, using an up-to-date compiler 
and without specifying any "-target" type options. The consequence of ignoring 
this warning is that reflective operations on this class will incorrectly 
indicate that it is *not* an inner class. 
[2011-12-15 17:06:25 - MobileApplication1] Dx warning: Ignoring InnerClasses attribute for an anonymous inner class 
(org.apache.commons.logging.impl.WeakHashtable$1) that doesn't come with an 
associated EnclosingMethod attribute. This class was probably produced by a 
compiler that did not target the modern .class file format. The recommended 
solution is to recompile the class from source, using an up-to-date compiler 
and without specifying any "-target" type options. The consequence of ignoring 
this warning is that reflective operations on this class will incorrectly 
indicate that it is *not* an inner class. 
[2011-12-15 17:06:25 - MobileApplication1] Dx warning: Ignoring InnerClasses attribute for an anonymous inner class 
(org.apache.commons.logging.LogFactory$1) that doesn't come with an 
associated EnclosingMethod attribute. This class was probably produced by a 
compiler that did not target the modern .class file format. The recommended 
solution is to recompile the class from source, using an up-to-date compiler 
and without specifying any "-target" type options. The consequence of ignoring 
this warning is that reflective operations on this class will incorrectly 
indicate that it is *not* an inner class. 
[2011-12-15 17:06:25 - MobileApplication1] Dx warning: Ignoring InnerClasses attribute for an anonymous inner class 
(org.apache.commons.logging.LogFactory$2) that doesn't come with an 
associated EnclosingMethod attribute. This class was probably produced by a 
compiler that did not target the modern .class file format. The recommended 
solution is to recompile the class from source, using an up-to-date compiler 
and without specifying any "-target" type options. The consequence of ignoring 
this warning is that reflective operations on this class will incorrectly 
indicate that it is *not* an inner class. 
[2011-12-15 17:06:25 - MobileApplication1] Dx warning: Ignoring InnerClasses attribute for an anonymous inner class 
(org.apache.commons.logging.LogFactory$3) that doesn't come with an 
associated EnclosingMethod attribute. This class was probably produced by a 
compiler that did not target the modern .class file format. The recommended 
solution is to recompile the class from source, using an up-to-date compiler 
and without specifying any "-target" type options. The consequence of ignoring 
this warning is that reflective operations on this class will incorrectly 
indicate that it is *not* an inner class. 
[2011-12-15 17:06:25 - MobileApplication1] Dx warning: Ignoring InnerClasses attribute for an anonymous inner class 
(org.apache.commons.logging.LogFactory$4) that doesn't come with an 
associated EnclosingMethod attribute. This class was probably produced by a 
compiler that did not target the modern .class file format. The recommended 
solution is to recompile the class from source, using an up-to-date compiler 
and without specifying any "-target" type options. The consequence of ignoring 
this warning is that reflective operations on this class will incorrectly 
indicate that it is *not* an inner class. 
[2011-12-15 17:06:25 - MobileApplication1] Dx warning: Ignoring InnerClasses attribute for an anonymous inner class 
(org.apache.commons.logging.LogFactory$5) that doesn't come with an 
associated EnclosingMethod attribute. This class was probably produced by a 
compiler that did not target the modern .class file format. The recommended 
solution is to recompile the class from source, using an up-to-date compiler 
and without specifying any "-target" type options. The consequence of ignoring 
this warning is that reflective operations on this class will incorrectly 
indicate that it is *not* an inner class. 
[2011-12-15 17:06:25 - MobileApplication1] Dx warning: Ignoring InnerClasses attribute for an anonymous inner class 
(org.apache.commons.logging.LogFactory$6) that doesn't come with an 
associated EnclosingMethod attribute. This class was probably produced by a 
compiler that did not target the modern .class file format. The recommended 
solution is to recompile the class from source, using an up-to-date compiler 
and without specifying any "-target" type options. The consequence of ignoring 
this warning is that reflective operations on this class will incorrectly 
indicate that it is *not* an inner class. 
Toggle HighlightingOpen in New WindowSelect All 

이 로그 채팅에서 오류는 다음과 같습니다 :

 
09-21 09:10:17.039: E/AndroidRuntime(4126): FATAL EXCEPTION: main 
09-21 09:10:17.039: E/AndroidRuntime(4126): java.lang.VerifyError: microsoft.exchange.webservices.data.EwsServiceXmlWriter 
09-21 09:10:17.039: E/AndroidRuntime(4126):  at microsoft.exchange.webservices.data.ServiceRequestBase.emit(Unknown Source) 
09-21 09:10:17.039: E/AndroidRuntime(4126):  at microsoft.exchange.webservices.data.ServiceRequestBase.validateAndEmitRequest(Unknown Source) 
09-21 09:10:17.039: E/AndroidRuntime(4126):  at microsoft.exchange.webservices.data.SimpleServiceRequestBase.internalExecute(Unknown Source) 
09-21 09:10:17.039: E/AndroidRuntime(4126):  at microsoft.exchange.webservices.data.MultiResponseServiceRequest.execute(Unknown Source) 
09-21 09:10:17.039: E/AndroidRuntime(4126):  at microsoft.exchange.webservices.data.ExchangeService.internalCreateItems(Unknown Source) 
09-21 09:10:17.039: E/AndroidRuntime(4126):  at microsoft.exchange.webservices.data.ExchangeService.createItem(Unknown Source) 
09-21 09:10:17.039: E/AndroidRuntime(4126):  at microsoft.exchange.webservices.data.Item.internalCreate(Unknown Source) 
09-21 09:10:17.039: E/AndroidRuntime(4126):  at microsoft.exchange.webservices.data.EmailMessage.internalSend(Unknown Source) 
09-21 09:10:17.039: E/AndroidRuntime(4126):  at microsoft.exchange.webservices.data.EmailMessage.send(Unknown Source) 
09-21 09:10:17.039: E/AndroidRuntime(4126):  at com.MobileApplication1.android.MainScreenActivity$1.onClick(MainScreenActivity.java:60) 
09-21 09:10:17.039: E/AndroidRuntime(4126):  at android.view.View.performClick(View.java:2485) 
09-21 09:10:17.039: E/AndroidRuntime(4126):  at android.view.View$PerformClick.run(View.java:9080) 
09-21 09:10:17.039: E/AndroidRuntime(4126):  at android.os.Handler.handleCallback(Handler.java:587) 
09-21 09:10:17.039: E/AndroidRuntime(4126):  at android.os.Handler.dispatchMessage(Handler.java:92) 
09-21 09:10:17.039: E/AndroidRuntime(4126):  at android.os.Looper.loop(Looper.java:123) 
09-21 09:10:17.039: E/AndroidRuntime(4126):  at android.app.ActivityThread.main(ActivityThread.java:3687) 
09-21 09:10:17.039: E/AndroidRuntime(4126):  at java.lang.reflect.Method.invokeNative(Native Method) 
09-21 09:10:17.039: E/AndroidRuntime(4126):  at java.lang.reflect.Method.invoke(Method.java:507) 
09-21 09:10:17.039: E/AndroidRuntime(4126):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867) 
09-21 09:10:17.039: E/AndroidRuntime(4126):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625) 
09-21 09:10:17.039: E/AndroidRuntime(4126):  at dalvik.system.NativeStart.main(Native Method) 
Toggle HighlightingOpen in New WindowSelect All 

나는 이미 이러한 라이브러리를 추가

은 콘솔에서 메시지입니다.

Exchange 웹 서비스 (EWS) 자바 API는 다음과 같은 제 3의 라이브러리

단일 패키지, microsoft.exchange.webservices.data 구성 및 요구 관리
  • 아파치 코 몬즈 HttpClient를 (평민 - httpclien.jar)
  • 아파치 코 몬즈 코덱 (평민 - codec.jar)
  • 아파치 코 몬즈 로깅 (평민 - codec.jar)
  • JCIFS (jcifs.jar)
  • EWS 자바 API.

무엇이 문제입니까?

나는 약간 연구를했다. Android가 이미 sdk 라이브러리에 로깅 및 httpclient가있는 곳을 볼 수 있습니다.

+0

어떤 생각? 도와주세요! – user999822

+0

이 게시물 또한 당신에게 흥미로울 수 있습니다 : http://stackoverflow.com/questions/9203073/problems-using-the-ews-java-api-on-android –

답변

1

Ansdroid에는 이미 commons-http (어떤 버전이 사용되었지만 4 이상)가 포함되어 있으므로 빌드 프로세스가 이미 포함 된 jar를 apk에 압축하지 않도록해야합니다.

또 다른 문제는 DX의 클래스 형식 불만입니다. 이는 오래된 것으로 다시 컴파일해야한다는 것입니다. 또한 의존성 버전을 확인하고 최근의 것을 사용하십시오 (당신이 maven/ivy를 사용한다면 더 쉬울 것입니다)

+0

이 라이브러리의 상위 버전은 없습니다. Apache Commons HttpClient (commons-httpclien.jar) 3.1 Apache Commons Logging (commons-codec.jar) 1.1.1 – user999822

+0

다음이 있습니다. http://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient http : //mvnrepository.com/artifact/commons-codec/commons-codec 또한 원본 버전의 소스를 가져 와서 최신 컴파일러로 다시 컴파일 할 수 있습니다. –

관련 문제