Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Didn't find class "org.apache.http.client.protocol.HttpClientContext" #506

Open
westmatrix opened this issue Mar 13, 2016 · 12 comments
Open

Comments

@westmatrix
Copy link

@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) 
@vbauer
Copy link
Contributor

vbauer commented Mar 13, 2016

@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 ?

@westmatrix
Copy link
Author

@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

@westmatrix
Copy link
Author

@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) 

@DevilGeek
Copy link

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;"

@Lugo239
Copy link

Lugo239 commented May 3, 2016

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.

@DevilGeek
Copy link

i got it working using the following

https://github.com/alipov/ews-android-api

@Lugo239
Copy link

Lugo239 commented May 3, 2016

Hi DevilGeek!
Thanks for the fast answer.
Can you post your build.gradle file (the relevant parts)?
I will check out your link.

@DevilGeek
Copy 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'

@Lugo239
Copy link

Lugo239 commented May 3, 2016

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!

@DilbagSandhu
Copy link

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

@FatmaMM
Copy link

FatmaMM commented Mar 17, 2019

do u find any way to get it ?? @DilbagSandhu

@DilbagSandhu
Copy link

it was long ago. I never tried after that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants