【问题标题】:NoClassDefFoundError: Failed resolution of: Lorg/apache/http/conn/ssl/DefaultHostnameVerifier;NoClassDefFoundError:解析失败:Lorg/apache/http/conn/ssl/DefaultHostnameVerifier;
【发布时间】:2015-04-14 16:47:36
【问题描述】:

我正在尝试在我正在制作的Office365 Android 应用程序中使用Exchange Web Services Java API,但不断收到此错误。

相关堆栈信息如下:

Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/conn/ssl/DefaultHostnameVerifier;
        at microsoft.exchange.webservices.data.core.EwsSSLProtocolSocketFactory.<clinit>(EwsSSLProtocolSocketFactory.java:86)
        at microsoft.exchange.webservices.data.core.ExchangeServiceBase.createConnectionSocketFactoryRegistry(ExchangeServiceBase.java:212)
        at microsoft.exchange.webservices.data.core.ExchangeServiceBase.initializeHttpClient(ExchangeServiceBase.java:194)
        at microsoft.exchange.webservices.data.core.ExchangeServiceBase.<init>(ExchangeServiceBase.java:170)
        at microsoft.exchange.webservices.data.core.ExchangeService.<init>(ExchangeService.java:3779)
        at com.microsoft.office365.connect.SendMailActivity.onBookMeetingButton1(SendMailActivity.java:140)

...

Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.http.conn.ssl.DefaultHostnameVerifier" on path: DexPathList[[zip file "/data/app/com.microsoft.office365.connect-2/base.apk"],nativeLibraryDirectories=[/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:86)
        at microsoft.exchange.webservices.data.core.ExchangeServiceBase.createConnectionSocketFactoryRegistry(ExchangeServiceBase.java:212)
        at microsoft.exchange.webservices.data.core.ExchangeServiceBase.initializeHttpClient(ExchangeServiceBase.java:194)
        at microsoft.exchange.webservices.data.core.ExchangeServiceBase.<init>(ExchangeServiceBase.java:170)
        at microsoft.exchange.webservices.data.core.ExchangeService.<init>(ExchangeService.java:3779)
        at com.microsoft.office365.connect.SendMailActivity.onBookMeetingButton1(SendMailActivity.java:140)

...

Suppressed: java.lang.ClassNotFoundException: org.apache.http.conn.ssl.DefaultHostnameVerifier
        at java.lang.Class.classForName(Native Method)
        at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
        at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
        ... 20 more
 Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

我的 /libs/ 文件夹中有 httpclient 4.3.jar,这些是我的依赖项:

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'

// base OData library:
compile group: 'com.microsoft.services', name: 'odata-engine-core', version: '0.12.1'
compile group: 'com.microsoft.services', name: 'odata-engine-android-impl', version: '0.12.1', ext:'aar'

// choose the discovery and outlook services
compile group: 'com.microsoft.services', name: 'discovery-services', version: '0.12.1'
compile group: 'com.microsoft.services', name: 'outlook-services', version: '0.12.1'

// Azure Active Directory Library
compile group: 'com.microsoft.aad', name: 'adal', version: '1.1.1'

//compile 'org.apache.httpcomponents:httpclient:4.4'
//compile 'org.apache.httpcomponents:httpcore:4.3.3'
//compile 'commons-logging:commons-logging:1.2'
//compile 'joda-time:joda-time:2.7'
}

是否有人能够发现问题或我可以如何解决它? 谢谢

【问题讨论】:

  • 又是我。找到解决方案了吗?
  • @Tinashe,没有放弃它!改为使用适用于 Android 的 office 365 sdk。
  • 您是否尝试过使用 office 365 sdk 访问共享资源?喜欢共享日历。
  • @Tinashe 我现在实际上正在努力解决这个问题。一直在接触sdk的开发者。几个小时后我回家时可以更新信息。
  • 非常感谢。谢谢。

标签: android android-gradle-plugin office365 apache-httpclient-4.x exchangewebservices


【解决方案1】:

我尝试添加以下依赖项。现在它对我来说工作正常

<dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpclient</artifactId>
    <version>4.4.1</version>
</dependency>

【讨论】:

  • 很棒的答案!我没有使用 android,但它为我修复了这个确切的错误!
  • @KrunalShah 你应该把它放在你的maven项目的pom.xml中
  • 如何添加这行@Rams
  • @RevathiManoharan 你需要在你的Java项目的Pom.xml中添加上述依赖
【解决方案2】:

遇到了同样的问题。我通过升级pom.xml 下的所有org.apache.httpcomponents 库来修复它

【讨论】:

    【解决方案3】:

    我也遇到过同样的问题,但修复了在 pom 中添加 httpclient-osgi

        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient-osgi</artifactId>
            <version>4.5.1</version>
        </dependency>
    

    效果很好..

    【讨论】:

      猜你喜欢
      • 2018-10-31
      • 2017-01-17
      • 1970-01-01
      • 2019-04-18
      • 2015-08-14
      • 1970-01-01
      • 1970-01-01
      • 2019-01-23
      • 1970-01-01
      相关资源
      最近更新 更多