ews-java-api
ews-java-api copied to clipboard
Didn't find class "org.apache.http.client.protocol.HttpClientContext"
@vbauer
I'm very new to Andriod developement and I'm trying this libary.
Gradle is like this:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.android.support:design:23.2.0'
compile 'com.microsoft.ews-java-api:ews-java-api:2.0'
}
There are some comipiling warnings:
Information:Gradle tasks [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:compileDebugSources, :app:compileDebugAndroidTestSources]
Warning:Dependency org.apache.httpcomponents:httpclient:4.4.1 is ignored for debug as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
Warning:Dependency commons-logging:commons-logging:1.2 is ignored for debug as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
Warning:Dependency org.apache.httpcomponents:httpclient:4.4.1 is ignored for release as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
Warning:Dependency commons-logging:commons-logging:1.2 is ignored for release as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
Eventually I launched the app in the emulator and clicked the button to make EWS call:
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.http.client.protocol.HttpClientContext" on path: DexPathList[[zip file "/data/app/domain.test.android.jasonyu.myfirstapp-2/base.apk"],nativeLibraryDirectories=[/data/app/domain.test.android.jasonyu.myfirstapp-2/lib/x86, /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.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.ExchangeService.<init>(ExchangeService.java:3718)
at domain.test.android.jasonyu.myfirstapp.MainActivity.onButtonGoClick(MainActivity.java:94)
@mytoughlife
Hello. Could you please try to check this solution: http://stackoverflow.com/questions/30755989/dependency-org-apache-httpcomponentshttpclient4-4-1-is-ignored-for-release-as ?
@vbauer Thanks for your reply.
That was the first thing I tried. "Make Project" succeeded, but failed with below error if I tried to run it:
:app:compileDebugSources UP-TO-DATE
:app:transformClassesWithDexForDebug
UNEXPECTED TOP-LEVEL EXCEPTION:
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_73\bin\java.exe'' finished with non-zero exit value 2
Then I read about http://stackoverflow.com/questions/33369163/execution-failed-for-task-apptransformclasseswithdexfordebug-while-implement
After adding multiDexEnabled true, I got
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources UP-TO-DATE
:app:transformClassesWithJarMergingForDebug FAILED
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/http/concurrent/Cancellable.class
@vbauer
I eventually managed to get rid of that error by doing this:
compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1'
compile ('com.microsoft.ews-java-api:ews-java-api:2.0') {
exclude group: 'org.apache.httpcomponents'
}
And then I was able to launch the app in the Nexus 5X Andriod 6.0 emulator, the app failed with a different error:
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/conn/ssl/DefaultHostnameVerifier;
at microsoft.exchange.webservices.data.core.EwsSSLProtocolSocketFactory.<clinit>(EwsSSLProtocolSocketFactory.java:84)
at microsoft.exchange.webservices.data.core.ExchangeServiceBase.createConnectionSocketFactoryRegistry(ExchangeServiceBase.java:244)
at microsoft.exchange.webservices.data.core.ExchangeServiceBase.initializeHttpClient(ExchangeServiceBase.java:198)
at microsoft.exchange.webservices.data.core.ExchangeServiceBase.<init>(ExchangeServiceBase.java:174)
at microsoft.exchange.webservices.data.core.ExchangeService.<init>(ExchangeService.java:3718)
at domain.test.android.jasonyu.myfirstapp.MainActivity.onButtonGoClick(MainActivity.java:94)
at java.lang.reflect.Method.invoke(Native Method)
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288)
at android.view.View.performClick(View.java:5198)
at android.view.View$PerformClick.run(View.java:21147)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.http.conn.ssl.DefaultHostnameVerifier" on path: DexPathList[[zip file "/data/app/domain.test.android.jasonyu.myfirstapp-2/base.apk"],nativeLibraryDirectories=[/data/app/domain.test.android.jasonyu.myfirstapp-2/lib/x86, /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.core.EwsSSLProtocolSocketFactory.<clinit>(EwsSSLProtocolSocketFactory.java:84)
at microsoft.exchange.webservices.data.core.ExchangeServiceBase.createConnectionSocketFactoryRegistry(ExchangeServiceBase.java:244)
at microsoft.exchange.webservices.data.core.ExchangeServiceBase.initializeHttpClient(ExchangeServiceBase.java:198)
at microsoft.exchange.webservices.data.core.ExchangeServiceBase.<init>(ExchangeServiceBase.java:174)
at microsoft.exchange.webservices.data.core.ExchangeService.<init>(ExchangeService.java:3718)
at domain.test.android.jasonyu.myfirstapp.MainActivity.onButtonGoClick(MainActivity.java:94)
This is very annoying, did anyone manage to make it work on android ?
i tried dependencies { compile 'com.microsoft.ews-java-api:ews-java-api:2.0' } but it give me "*Didn't find class "org.apache.http.client.protocol.HttpClientContext" *"
and i tried
compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1' compile ('com.microsoft.ews-java-api:ews-java-api:2.0') { exclude group: 'org.apache.httpcomponents' }
but i get "Failed resolution of: Lorg/apache/http/client/protocol/HttpClientContext;"
I cant get the api working properly.
The "Didn't find class "org.apache.http.client.protocol.HttpClientContext" issue is omnipresent. When i try to fix it with another httpclient version like for example 4.4.1 or 4.3.5.1 i get "Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/conn/ssl/DefaultHostnameVerifier;"
Would be awesome if somebody could help.
i got it working using the following
https://github.com/alipov/ews-android-api
Hi DevilGeek! Thanks for the fast answer. Can you post your build.gradle file (the relevant parts)? I will check out your link.
Just read the link in my previous post. nothing really relevant in my build.gradle
compile files('libs/ews-android-api.jar')
compile 'joda-time:joda-time:2.8'
Created and compiled the ews-android-api.jar. I can start the application and iam able to send the request thanks DevilGeek!
EDIT: It works! DevilGeek you are my man! Thanks for saving me!
hi lugo239 can you please tell me how to create and compile the ems-android-api.jar, i dont know how to and where to run the commands they written at: https://github.com/alipov/ews-android-api
do u find any way to get it ?? @DilbagSandhu
it was long ago. I never tried after that.