迁移到androidx时,我发现模块httpmime-4.0.1.jarhttpmime-4.3.6.jar有一些冲突。

我在gradle中尝试了一些代码:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    useLibrary 'org.apache.http.legacy'
    defaultConfig {
        applicationId "com.links.meplinks"
        minSdkVersion 19
        targetSdkVersion 29
        versionCode 29
        versionName "1.15.11"
        multiDexEnabled true

        android.compileOptions.sourceCompatibility 1.8
        android.compileOptions.targetCompatibility 1.8
        packagingOptions {
            exclude 'META-INF/LICENSE.txt'
            exclude 'META-INF/NOTICE.txt'
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
repositories {
    maven { url "https://dl.bintray.com/hani-momanii/maven" }
}
dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'androidx.appcompat:appcompat:1.0.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'



    compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
    compile('org.apache.httpcomponents:httpmime:4.3.6') {
        exclude module: 'httpclient'
        exclude module:'httpmime-4.0.1'
    }


}



在以下位置找到重复的类org.apache.http.entity.mime.FormBodyPart
模块httpmime-4.0.1.jar(httpmime-4.0.1.jar)和httpmime-4.3.6.jar
(org.apache.httpcomponents:httpmime:4.3.6)重复的类
在模块中找到org.apache.http.entity.mime.HttpMultipart
httpmime-4.0.1.jar(httpmime-4.0.1.jar)和httpmime-4.3.6.jar
(org.apache.httpcomponents:httpmime:4.3.6)重复的类
在模块中找到org.apache.http.entity.mime.HttpMultipart $ 1
httpmime-4.0.1.jar(httpmime-4.0.1.jar)和httpmime-4.3.6.jar
(org.apache.httpcomponents:httpmime:4.3.6)重复的类
在模块中找到org.apache.http.entity.mime.HttpMultipartMode
httpmime-4.0.1.jar(httpmime-4.0.1.jar)和httpmime-4.3.6.jar
(org.apache.httpcomponents:httpmime:4.3.6)重复的类
在模块httpmime-4.0.1.jar中找到org.apache.http.entity.mime.MIME
(httpmime-4.0.1.jar)和httpmime-4.3.6.jar
(org.apache.httpcomponents:httpmime:4.3.6)重复的类
在模块中找到org.apache.http.entity.mime.MinimalField
httpmime-4.0.1.jar(httpmime-4.0.1.jar)和httpmime-4.3.6.jar
(org.apache.httpcomponents:httpmime:4.3.6)重复的类
在模块中找到的org.apache.http.entity.mime.MultipartEntity
httpmime-4.0.1.jar(httpmime-4.0.1.jar)和httpmime-4.3.6.jar
(org.apache.httpcomponents:httpmime:4.3.6)重复的类
org.apache.http.entity.mime.content.AbstractContentBody位于
模块httpmime-4.0.1.jar(httpmime-4.0.1.jar)和httpmime-4.3.6.jar
(org.apache.httpcomponents:httpmime:4.3.6)重复的类
在模块中找到的org.apache.http.entity.mime.content.ContentBody
httpmime-4.0.1.jar(httpmime-4.0.1.jar)和httpmime-4.3.6.jar
(org.apache.httpcomponents:httpmime:4.3.6)重复的类
在模块中找到的org.apache.http.entity.mime.content.FileBody
httpmime-4.0.1.jar(httpmime-4.0.1.jar)和httpmime-4.3.6.jar
(org.apache.httpcomponents:httpmime:4.3.6)重复的类
在模块中找到的org.apache.http.entity.mime.content.InputStreamBody
httpmime-4.0.1.jar(httpmime-4.0.1.jar)和httpmime-4.3.6.jar
(org.apache.httpcomponents:httpmime:4.3.6)重复的类
在模块中找到的org.apache.http.entity.mime.content.StringBody
httpmime-4.0.1.jar(httpmime-4.0.1.jar)和httpmime-4.3.6.jar
(org.apache.httpcomponents:httpmime:4.3.6)

转到文档以了解如何解决依赖关系解析
错误。

最佳答案

尝试将httpmime更新为4.5.6并排除httpcore-4.4.10模块

implementation 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
implementation ('org.apache.httpcomponents:httpmime:4.5.6'){
     exclude module: 'httpclient'
     exclude module:'httpcore-4.4.10'
}

09-27 18:14