在使用Apache http类构建我的gradle时,我遇到了重复类错误。以下是我遇到的一些错误:
Duplicate class org.apache.http.HttpHeaders found in modules jetified-httpclient-android-4.3.5.1.jar (org.apache.httpcomponents:httpclient-android:4.3.5.1) and jetified-org.jbundle.util.osgi.wrapped.org.apache.http.client-4.1.2.jar (org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2)
Duplicate class org.apache.http.TruncatedChunkException found in modules jetified-httpclient-android-4.3.5.1.jar (org.apache.httpcomponents:httpclient-android:4.3.5.1) and jetified-org.jbundle.util.osgi.wrapped.org.apache.http.client-4.1.2.jar (org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2)
Duplicate class org.apache.http.annotation.GuardedBy found in modules jetified-httpclient-android-4.3.5.1.jar (org.apache.httpcomponents:httpclient-android:4.3.5.1) and jetified-org.jbundle.util.osgi.wrapped.org.apache.http.client-4.1.2.jar (org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2)
Duplicate class org.apache.http.annotation.Immutable found in modules jetified-httpclient-android-4.3.5.1.jar (org.apache.httpcomponents:httpclient-android:4.3.5.1) and jetified-org.jbundle.util.osgi.wrapped.org.apache.http.client-4.1.2.jar (org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2)
Duplicate class org.apache.http.annotation.NotThreadSafe found in modules jetified-httpclient-android-4.3.5.1.jar (org.apache.httpcomponents:httpclient-android:4.3.5.1) and jetified-org.jbundle.util.osgi.wrapped.org.apache.http.client-4.1.2.jar (org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2)
Duplicate class org.apache.http.annotation.ThreadSafe found in modules jetified-httpclient-android-4.3.5.1.jar (org.apache.httpcomponents:httpclient-android:4.3.5.1) and jetified-org.jbundle.util.osgi.wrapped.org.apache.http.client-4.1.2.jar (org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2)
Duplicate class org.apache.http.auth.ContextAwareAuthScheme found in modules jetified-httpclient-android-4.3.5.1.jar (org.apache.httpcomponents:httpclient-android:4.3.5.1) and jetified-org.jbundle.util.osgi.wrapped.org.apache.http.client-4.1.2.jar (org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2)
Duplicate class org.apache.http.client.AuthCache found in modules jetified-httpclient-android-4.3.5.1.jar (org.apache.httpcomponents:httpclient-android:4.3.5.1) and jetified-org.jbundle.util.osgi.wrapped.org.apache.http.client-4.1.2.jar (org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2)
Duplicate class org.apache.http.client.RedirectStrategy found in modules jetified-httpclient-android-4.3.5.1.jar (org.apache.httpcomponents:httpclient-android:4.3.5.1) and jetified-org.jbundle.util.osgi.wrapped.org.apache.http.client-4.1.2.jar (org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2)
Duplicate class org.apache.http.client.entity.DecompressingEntity found in modules jetified-httpclient-android-4.3.5.1.jar (org.apache.httpcomponents:httpclient-android:4.3.5.1) and jetified-org.jbundle.util.osgi.wrapped.org.apache.http.client-4.1.2.jar (org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2)
Duplicate class org.apache.http.client.entity.DeflateDecompressingEntity found in modules jetified-httpclient-android-4.3.5.1.jar (org.apache.httpcomponents:httpclient-android:4.3.5.1) and jetified-org.jbundle.util.osgi.wrapped.org.apache.http.client-4.1.2.jar (org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2)
Duplicate class org.apache.http.client.entity.GzipDecompressingEntity found in modules jetified-httpclient-android-4.3.5.1.jar (org.apache.httpcomponents:httpclient-android:4.3.5.1) and jetified-org.jbundle.util.osgi.wrapped.org.apache.http.client-4.1.2.jar (org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2)
Duplicate class org.apache.http.client.protocol.RequestAcceptEncoding found in modules jetified-httpclient-android-4.3.5.1.jar (org.apache.httpcomponents:httpclient-android:4.3.5.1) and jetified-org.jbundle.util.osgi.wrapped.org.apache.http.client-4.1.2.jar (org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2)
Duplicate class org.apache.http.client.protocol.RequestAuthCache found in modules jetified-httpclient-android-4.3.5.1.jar (org.apache.httpcomponents:httpclient-android:4.3.5.1) and jetified-org.jbundle.util.osgi.wrapped.org.apache.http.client-4.1.2.jar (org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2)
Duplicate class org.apache.http.client.protocol.RequestClientConnControl found in modules jetified-httpclient-android-4.3.5.1.jar (org.apache.httpcomponents:httpclient-android:4.3.5.1) and jetified-org.jbundle.util.osgi.wrapped.org.apache.http.client-4.1.2.jar (org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2)
Duplicate class org.apache.http.client.protocol.ResponseContentEncoding found in modules jetified-httpclient-android-4.3.5.1.jar (org.apache.httpcomponents:httpclient-android:4.3.5.1) and jetified-org.jbundle.util.osgi.wrapped.org.apache.http.client-4.1.2.jar (org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2)
Duplicate class org.apache.http.client.utils.Idn found in modules jetified-httpclient-android-4.3.5.1.jar (org.apache.httpcomponents:httpclient-android:4.3.5.1) and jetified-org.jbundle.util.osgi.wrapped.org.apache.http.client-4.1.2.jar (org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2)
Duplicate class org.apache.http.client.utils.JdkIdn found in modules jetified-httpclient-android-4.3.5.1.jar (org.apache.httpcomponents:httpclient-android:4.3.5.1) and jetified-org.jbundle.util.osgi.wrapped.org.apache.http.client-4.1.2.jar (org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2)
Duplicate class org.apache.http.client.utils.Punycode found in modules jetified-httpclient-android-4.3.5.1.jar (org.apache.httpcomponents:httpclient-android:4.3.5.1) and jetified-org.jbundle.util.osgi.wrapped.org.apache.http.client-4.1.2.jar (org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2)
Duplicate class org.apache.http.client.utils.Rfc3492Idn found in modules jetified-httpclient-android-4.3.5.1.jar (org.apache.httpcomponents:httpclient-android:4.3.5.1) and jetified-org.jbundle.util.osgi.wrapped.org.apache.http.client-4.1.2.jar (org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2)
Duplicate class org.apache.http.conn.HttpRoutedConnection found in modules jetified-httpclient-android-4.3.5.1.jar
这是我的成绩单:
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
useLibrary 'org.apache.http.legacy'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dexOptions {
javaMaxHeapSize "4g"
}
...
defaultConfig {
applicationId "com.myapp.android"
//Oreo 8.0
minSdkVersion 26
// Android 11
targetSdkVersion 30
}
...
}
dependencies {
...
implementation ('org.apache.httpcomponents:httpclient-android:4.3.5.1') {
exclude group: 'org.apache.http'
}
implementation('org.apache.httpcomponents:httpmime:4.3') {
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
...
}
implementation'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
}
我需要访问以下类:HttpMultipartMode, MultipartEntityBuilder, ContentType, HttpPost, HttpRequestBase, HttpUriRequest
。这就是为什么这个库的组合适合我。但是它在设备上运行之前就失败了。感谢任何支持!
1条答案
按热度按时间h9a6wy2h1#
用这个