OfficeDev / ews-java-api

A java client library to access Exchange web services. The API works against Office 365 Exchange Online as well as on premises Exchange.
MIT License
870 stars 560 forks source link

java.lang.NoSuchFieldError: No field INSTANCE of type Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier; in class Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier; or its superclasses (declaration of 'org.apache.http.conn.ssl.AllowAllHostnameVerifier' appears in /system/framework/framework.jar:classes2.dex) #693

Open FatmaMM opened 5 years ago

FatmaMM commented 5 years ago

this error i don't how to solve it ?? java.lang.NoSuchFieldError: No field INSTANCE of type Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier; in class Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier; or its superclasses (declaration of 'org.apache.http.conn.ssl.AllowAllHostnameVerifier' appears in /system/framework/framework.jar:classes2.dex)

pkropachev commented 5 years ago

How do you get this error? In what cases?

FatmaMM commented 5 years ago

I get this error when i import the library as jar file into the project implementation files('libs/ews-java-api-2.0.jar')

pkropachev commented 5 years ago

EWS Java API has his own dependencies. Are sure that your declaration of dependencies is correct? In my case all is ok.

plugins {
    // Apply the java plugin to add support for Java
    id 'java'

    // Apply the application plugin to add support for building an application
    id 'application'
}

repositories {
    // Use jcenter for resolving your dependencies.
    // You can declare any Maven/Ivy/file repository here.
    jcenter()
}

dependencies {
    implementation 'com.microsoft.ews-java-api:ews-java-api:2.0'
}

// Define the main class for the application
mainClassName = 'ews.gradle.App'
FatmaMM commented 5 years ago

yes. But when i add ((implementation 'com.microsoft.ews-java-api:ews-java-api:2.0')) i get this error :Program type already present: microsoft.exchange.webservices.data.ISelfValidate Message{kind=ERROR, text=Program type already present: microsoft.exchange.webservices.data.ISelfValidate, sources=[Unknown source file], tool name=Optional.of(D8)}

pkropachev commented 5 years ago

Can you attach the sample of project which generates such error?

WenqiangTu commented 5 years ago

I have same error,just create a new project use android sutdio 3.5 implementation 'com.microsoft.ews-java-api:ews-java-api:2.0' after build show error 'More than one file was found with OS independent path 'META-INF/DEPENDENCIES'' then i add packagingOptions { exclude 'META-INF/DEPENDENCIES' } in app/build.gradle,and build success add code in guide and run,then show error

java.lang.NoSuchFieldError: No field INSTANCE of type Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier; in class Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier; or its superclasses (declaration of 'org.apache.http.conn.ssl.AllowAllHostnameVerifier' appears in /system/framework/framework.jar:classes2.dex)

KushtrimPacaj commented 5 years ago

Android ( AOSP ), has the same file ( org/apache/http/conn/ssl/AllowAllHostnameVerifier ) in framework.jar , and it doesn't contain the INSTANCE field: http://androidxref.com/7.1.2_r36/xref/frameworks/base/core/java/org/apache/http/conn/ssl/AllowAllHostnameVerifier.java

Unfortunately this takes precedence to the app version, and this is what is used in runtime. So you get a runtime error.

As far as I understand, the only way to solve this would be to change the signature of the app lib versions, for example org/apache-android/http/conn/ssl/AllowAllHostnameVerifier, so as not to clash with the system ones.

Seems like someone already did this: https://github.com/alipov/ews-android-api

xx113355 commented 3 years ago

I also have this error.

Caused by: java.lang.NoSuchFieldError: No static field INSTANCE of type Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier; in class Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier

Code: ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);

zhangll2020 commented 3 years ago

me too,I have this error,how to resolve it