【问题标题】:Duplicate class conflict in Android studioAndroid工作室中的重复类冲突
【发布时间】:2019-11-24 06:12:21
【问题描述】:

迁移到 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) 重复类 org.apache.http.entity.mime.MIME 在模块 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.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)

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

【问题讨论】:

  • 看看你的错误信息的最后一行——上面写着Go to the documentation to learn how to Fix dependency resolution errors.

标签: java android apache jar


【解决方案1】:

尝试将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'
}

【讨论】:

    猜你喜欢
    • 2016-11-04
    • 2016-10-25
    • 1970-01-01
    • 2013-10-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多