![](/img/trans.png)
[英]java.lang.NoClassDefFoundError: org/apache/http/impl/conn/PoolingClientConnectionManager
[英]org.apache.http.client-4.3.6: java.lang.NoClassDefFoundError: org.apache.http.impl.conn.PoolingHttpClientConnectionManager
我正在使用Android。 我正在尝试为Unirest库安装依赖项(没有maven)。 我添加了依赖项的确切版本,即:httpclient 4.3.6,httpmime 4.3.6,httpasyncclient 4.0.2。
但是,我仍然收到此错误:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.abdulwasae.odnvt_1, PID: 12678
java.lang.NoClassDefFoundError: org.apache.http.impl.conn.PoolingHttpClientConnectionManager
at com.mashape.unirest.http.options.Options.refresh(Options.java:72)
at com.mashape.unirest.http.options.Options.<clinit>(Options.java:46)
at com.mashape.unirest.http.HttpClientHelper.prepareRequest(HttpClientHelper.java:151)
at com.mashape.unirest.http.HttpClientHelper.request(HttpClientHelper.java:131)
at com.mashape.unirest.request.BaseRequest.asJson(BaseRequest.java:68)
at com.abdulwasae.odnvt_1.ODFragment$2.onClick(ODFragment.java:225)
at android.view.View.performClick(View.java:4856)
at android.view.View$PerformClick.run(View.java:19956)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:211)
at android.app.ActivityThread.main(ActivityThread.java:5373)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1020)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815)
根据相关的Apache Javadocs ,此定义早于4.3版本就存在于org.apache.httpclient中。
我感到难过。 任何帮助,将不胜感激。
另外,这是我的gradle快照,以防万一:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.abdulwasae.odnvt_1"
minSdkVersion 21
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/NOTICE' // will not include NOTICE file
exclude 'META-INF/LICENSE' // will not include LICENSE file
exclude 'META-INF/DEPENDENCIES' // will not include DEPENDENCIES file
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:design:22.2.1'
compile files('libs/unirest-java-1.4.7.jar')
compile files('libs/httpasyncclient-4.0.2.jar')
compile files('libs/httpclient-4.3.6.jar')
compile files('libs/httpmime-4.3.6.jar')
}
更新我检查以确认是否可以在任何添加的依赖项中找到该麻烦的类。 而且,是的,它确实显示在httpclient-4.3.6.jar中
我不知道接下来要检查什么。
使用unirest-java-1.4.9-SNAPSHOT-withDependency-ShadedForAndroid 。 可以按照本教程进行构建。
NoClassDefFoundError始终表示您缺少一个jar文件。
java.lang.NoClassDefFoundError:org.apache.http.impl.conn.PoolingHttpClientConnectionManager
看起来像它在httpcomponent-client中,尝试添加:
compile 'org.apache.httpcomponents:httpcomponents-client:4.5.2'
到您的构建文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.