Gradle图书馆冲突

时间:2018-08-02 07:50:21

标签: android gradle

我在库中发生冲突,无法解决,并且错误始终是

多个dex文件定义了Lorg / apache / http / impl / client / DefaultRequestDirector;

如果我未实现jackson2和Robospice库,则该项目将编译并运行,但是,我需要这样做。

这是我的礼物

dependencies {


    implementation files('libs/speedchecker-android-sdk-1.3.jar')


    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'com.google.code.gson:gson:2.8.4'
    implementation 'com.squareup.okhttp:okhttp:2.5.0'
    implementation 'fr.avianey.com.viewpagerindicator:library:2.4.1.1@aar'
    implementation 'com.google.android.gms:play-services-auth:15.0.1'
    implementation 'com.google.android.gms:play-services-gcm:15.0.1'

    implementation 'com.google.firebase:firebase-core:16.0.1'
    implementation 'com.google.firebase:firebase-messaging:17.1.0'
    implementation 'com.google.firebase:firebase-database:16.0.1'

    implementation 'com.google.android.gms:play-services-maps:15.0.1'
    implementation 'info.hoang8f:android-segmented:1.0.6'
    implementation 'com.google.code.ksoap2-android:ksoap2-android:2.6.0'
    testImplementation 'junit:junit:4.12'
    implementation('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
        transitive = true;
    }

    implementation('com.google.http-client:google-http-client-jackson2:1.19.0') {
        exclude module: 'commons-io' 
        exclude module: 'xpp3'
        exclude group: 'stax'
    }
    implementation('com.octo.android.robospice:robospice-google-http-client:1.4.14') {
        exclude module: 'commons-io'
        exclude group: 'org.apache.commons'
    }
}

尝试了几个小时后,我发现冲突是由以下3个引起的(当我购买速度测试jar文件库时,这两个库一起出现,因此在升级构建工具后,会发生冲突)

implementation files('libs/speedchecker-android-sdk-1.3.jar')

implementation('com.google.http-client:google-http-client-jackson2:1.19.0') {
    exclude module: 'commons-io' 
    exclude module: 'xpp3'
    exclude group: 'stax'
}

implementation('com.octo.android.robospice:robospice-google-http-client:1.4.14') {
    exclude module: 'commons-io'
    exclude group: 'org.apache.commons'
}

2 个答案:

答案 0 :(得分:0)

更改gradle.property和multidexenable = true;

org.gradle.jvmargs=-Xmx1024m

compile 'com.android.support:multidex:1.0.1'

,还包括

 multiDexEnabled true

答案 1 :(得分:0)

似乎您正在混合不应混用的库

查看您的构建文件,这些库是冲突的:

  1. firebase包含两个相互冲突的版本16.0.117.1.0
  2. firebase和gcm(版本15.0.1)都存在依赖性,这也有冲突

摆脱这些,它应该可以毫无问题地构建