Error Lorg/apache/http/client/protocol/HttpClientContext;

  • Respuestas:0
  • AbiertoSin chinchetaSin solución
  • Posts del Foro: 1

1 dic. 2020 11:39:05 vía Web

Hola muy buenas, estoy intentando enviar un correo electrónico mediante EWS en Android Studio pero me es imposible iniciar el ExchangeServices debido a que siempre me da el mismo error.

He seguido diferentes hilos de GitHub y otras plataformas y todo el mundo lo hace así, no entiendo ese error cuando tengo el build.gradle correctamente.

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.reunionios, PID: 27372
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/client/protocol/HttpClientContext;
    at microsoft.exchange.webservices.data.core.ExchangeServiceBase.initializeHttpContext(ExchangeServiceBase.java:261)
    at microsoft.exchange.webservices.data.core.ExchangeServiceBase.setUseDefaultCredentials(ExchangeServiceBase.java:677)
    at microsoft.exchange.webservices.data.core.ExchangeServiceBase.<init>(ExchangeServiceBase.java:173)
    at microsoft.exchange.webservices.data.core.ExchangeServiceBase.<init>(ExchangeServiceBase.java:179)
    at microsoft.exchange.webservices.data.core.ExchangeService.<init>(ExchangeService.java:3729)
    at com.example.reunionios.Provaews$1.onClick(Provaews.java:55)
    at android.view.View.performClick(View.java:5610)
    at android.view.View$PerformClick.run(View.java:22265)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6077)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
 Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.http.client.protocol.HttpClientContext" on path: DexPathList[[zip file "/data/app/com.example.reunionios-2/base.apk"],nativeLibraryDirectories=[/data/app/com.example.reunionios-2/lib/x86, /system/lib, /vendor/lib]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
    at microsoft.exchange.webservices.data.core.ExchangeServiceBase.initializeHttpContext(ExchangeServiceBase.java:261) 
    at microsoft.exchange.webservices.data.core.ExchangeServiceBase.setUseDefaultCredentials(ExchangeServiceBase.java:677) 
    at microsoft.exchange.webservices.data.core.ExchangeServiceBase.<init>(ExchangeServiceBase.java:173) 
    at microsoft.exchange.webservices.data.core.ExchangeServiceBase.<init>(ExchangeServiceBase.java:179) 
    at microsoft.exchange.webservices.data.core.ExchangeService.<init>(ExchangeService.java:3729) 
    at com.example.reunionios.Provaews$1.onClick(Provaews.java:55) 
    at android.view.View.performClick(View.java:5610) 
    at android.view.View$PerformClick.run(View.java:22265) 
    at android.os.Handler.handleCallback(Handler.java:751) 
    at android.os.Handler.dispatchMessage(Handler.java:95) 
    at android.os.Looper.loop(Looper.java:154) 
    at android.app.ActivityThread.main(ActivityThread.java:6077) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756) 

Este es mi build.gradle actual.

android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
useLibrary  'org.apache.http.legacy'
packagingOptions{
    exclude "META-INF/DEPENDENCIES"
}

dependencies {

// implementation group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1'

implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.3'
implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.+'
implementation 'androidx.preference:preference:1.1.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.appcompat:appcompat:1.0.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

implementation files('libs/ews-java-api-2.0.jar')
implementation 'dnsjava:dnsjava:2.1.6'

Trabajo con esto

minSdkVersion 16
targetSdkVersion 30

Contesta el/la primero/a
Recomendado por NextPit