添加依赖项后无法合并dex [英] Unable to merge dex after adding dependencies

查看:69
本文介绍了添加依赖项后无法合并dex的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了错误:

错误:任务':app:transformDexArchiveWithExternalLibsDexMergerForPaidFreeDebug'的执行失败.java.lang.RuntimeException:com.android.builder.dexing.DexArchiveMergerException:无法合并dex

添加以下两个依赖项之后:

 实现'cn.aigestudio.wheelpicker:WheelPicker:1.1.2'实施'com.prolificinteractive:material-calendarview:1.4.3' 

这是我所有的依赖项:

 依赖项{编译'com.android.support:multidex:1.0.2'编译('com.github.florent37:materialviewpager:1.2.0@aar'){可传递=真}编译'com.android.support:multidex:1.0.0'编译文件('libs/droidText.0.2.jar')编译'commons-io:commons-io:2.5'编译'com.google.code.findbugs:jsr305:3.0.0'//在应用帐单中编译'com.anjlab.android.iab.v3:library:1.0.44'编译'org.solovyev.android:checkout:1.2.1'//编译'com.github.simbiose:Encryption:2.0.1'编译'com.android.support:support-v13:24.2.1'编译'com.android.support:support-v4:24.2.1'编译'com.android.support:cardview-v7:24.2.1'编译'com.android.support:appcompat-v7:24.2.1'编译'com.android.support:design:24.2.1'编译'me.everything:providers-android:1.0.1'//dateTime Picker实现'cn.aigestudio.wheelpicker:WheelPicker:1.1.2'实施'com.prolificinteractive:material-calendarview:1.4.3'//约会时间编译'net.danlew:android.joda:2.9.9'编译'com.readystatesoftware.sqliteasset:sqliteassethelper:+'编译'com.github.danysantiago:sendgrid-android:1'编译'com.google.android.gms:play-services-ads:10.0.1'编译'com.google.firebase:firebase-ads:10.0.1'//记录编译'com.jakewharton.timber:timber:4.5.1'//改造编译'com.squareup.retrofit2:retrofit:2.3.0'编译'com.squareup.retrofit2:converter-gson:2.3.0'编译'com.squareup.retrofit2:adapter-rxjava2:2.3.0'编译'com.squareup.retrofit2:converter-scalars:2.3.0'//Rx编译'io.reactivex.rxjava2:rxandroid:2.0.1'编译'io.reactivex.rxjava2:rxjava:2.0.8'//牛油刀编译'com.jakewharton:butterknife:8.4.0'注解处理器'com.jakewharton:butterknife-compiler:8.4.0'testCompile'junit:junit:4.12'testCompile'org.apache.maven:maven-ant-tasks:2.1.3'testCompile'org.robolectric:robolectric:3.1-rc1'testCompile'org.robolectric:shadows-support-v4:3.1-rc1'testCompile'org.glassfish:javax.annotation:10.0-b28'testCompile'org.mockito:mockito-core:2.0.7-beta'testCompile'org.hamcrest:hamcrest-all:1.3'testCompile'org.robolectric:shadows-multidex:3.1-rc1'testCompile'org.assertj:assertj-core:1.7.1'编译"org.jetbrains.kotlin:kotlin-stdlib-jre7:$ kotlin_version"} 

我的默认配置:

  defaultConfig {applicationId"com.webnation.text2email"minSdkVersion 19targetSdkVersion 19multiDexEnabled是} 

我已经升级了内存,添加了multiDexEnabled,添加了对多dex的支持库.

有趣的是,我不得不添加

 排除"META-INF/DEPENDENCIES" 

以使其变为multidex错误.

我似乎找不到解决方法.

详细错误:

错误:07:48:24.286 [错误] [org.gradle.internal.buildevents.BuildExceptionReporter]07:48:24.286 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]失败:生成失败,出现异常.07:48:24.286 [错误] [org.gradle.internal.buildevents.BuildExceptionReporter]07:48:24.286 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] *出了什么问题:07:48:24.286 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]任务':app:transformClassesWithMultidexlistForPaidFreeDebug'的执行失败.07:48:24.287 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]> java.io.IOException:无法编写[/Users/kristywelsh/Dropbox/SMS2Email1/app/build/intermediates/multi-dex/paidFree/debug/componentClasses.jar](无法读取[/Users/kristywelsh/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpcore/4.3.2/31fbbff1ddbf98f3aa7377c94d33b0447c646b6e/httpcore-4.3.2.jar(;;;;;; **.class)](重复的zip条目[httpcore-4.3.2.jar:org/apache/http/annotation/NotThreadSafe.class]))07:48:24.287 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]07:48:24.287 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] *尝试:07:48:24.287 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]使用--stacktrace选项运行以获取堆栈跟踪.07:48:24.287 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]07:48:24.287 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] *在.

I am getting the error:

Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForPaidFreeDebug'. java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

After adding the following two dependencies:

implementation 'cn.aigestudio.wheelpicker:WheelPicker:1.1.2'
implementation 'com.prolificinteractive:material-calendarview:1.4.3'

Here are all of my dependencies:

dependencies {
compile 'com.android.support:multidex:1.0.2'
compile('com.github.florent37:materialviewpager:1.2.0@aar') {
    transitive = true
}
compile 'com.android.support:multidex:1.0.0'
compile files('libs/droidText.0.2.jar')
compile 'commons-io:commons-io:2.5'
compile 'com.google.code.findbugs:jsr305:3.0.0'
// in app billing
compile 'com.anjlab.android.iab.v3:library:1.0.44'
compile 'org.solovyev.android:checkout:1.2.1'
//
compile 'com.github.simbiose:Encryption:2.0.1'
compile 'com.android.support:support-v13:24.2.1'
compile 'com.android.support:support-v4:24.2.1'
compile 'com.android.support:cardview-v7:24.2.1'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'me.everything:providers-android:1.0.1'
//dateTime Picker
implementation 'cn.aigestudio.wheelpicker:WheelPicker:1.1.2'
implementation 'com.prolificinteractive:material-calendarview:1.4.3'
//Date Time
compile 'net.danlew:android.joda:2.9.9'
compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:+'
compile 'com.github.danysantiago:sendgrid-android:1'
compile 'com.google.android.gms:play-services-ads:10.0.1'
compile 'com.google.firebase:firebase-ads:10.0.1'
//Logging
compile 'com.jakewharton.timber:timber:4.5.1'
//Retrofit
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
compile 'com.squareup.retrofit2:converter-scalars:2.3.0'
//Rx
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'io.reactivex.rxjava2:rxjava:2.0.8'

//butterknife
compile 'com.jakewharton:butterknife:8.4.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'

testCompile 'junit:junit:4.12'
testCompile 'org.apache.maven:maven-ant-tasks:2.1.3'
testCompile 'org.robolectric:robolectric:3.1-rc1'
testCompile 'org.robolectric:shadows-support-v4:3.1-rc1'
testCompile 'org.glassfish:javax.annotation:10.0-b28'
testCompile 'org.mockito:mockito-core:2.0.7-beta'
testCompile 'org.hamcrest:hamcrest-all:1.3'
testCompile 'org.robolectric:shadows-multidex:3.1-rc1'
testCompile 'org.assertj:assertj-core:1.7.1'
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
}

My default config:

defaultConfig {

    applicationId "com.webnation.text2email"
    minSdkVersion 19
    targetSdkVersion 19
    multiDexEnabled true

}

I have upgraded the memory, added multiDexEnabled, added the support library for multi-dex.

Interesting, I had to add

exclude 'META-INF/DEPENDENCIES'

in order to get it to the multidex error.

I can't seem to find a solution.

Detailed error:

Error:07:48:24.286 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 07:48:24.286 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception. 07:48:24.286 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 07:48:24.286 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong: 07:48:24.286 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Execution failed for task ':app:transformClassesWithMultidexlistForPaidFreeDebug'. 07:48:24.287 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > java.io.IOException: Can't write [/Users/kristywelsh/Dropbox/SMS2Email1/app/build/intermediates/multi-dex/paidFree/debug/componentClasses.jar] (Can't read [/Users/kristywelsh/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpcore/4.3.2/31fbbff1ddbf98f3aa7377c94d33b0447c646b6e/httpcore-4.3.2.jar(;;;;;;**.class)] (Duplicate zip entry [httpcore-4.3.2.jar:org/apache/http/annotation/NotThreadSafe.class])) 07:48:24.287 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 07:48:24.287 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Try: 07:48:24.287 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Run with --stacktrace option to get the stack trace. 07:48:24.287 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 07:48:24.287 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Get more help at https://help.gradle.org 07:48:24.287 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger] 07:48:24.287 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger] BUILD FAILED in 34s

解决方案

Duplicate zip entry [httpcore-4.3.2.jar:org/apache/http/annotation/NotThreadSafe.class]

You are picking up two copies of this Java class, from sources that Gradle is not netting out in its dependency resolution process.

One possibility is that one of your new dependencies has a transitive dependency on Apache HttpCore, but that libs/droidText.0.2.jar or one of your other dependencies has its own copy of org.apache.http.annotation.NotThreadSafe.

Android Studio has the "External Libraries" portion of the project tree, if you are in the Project view (rather than the default Android view):

The only way that I know of to track this down is to start sifting through your libraries and try to identify the 2+ that have org.apache.http.annotation.NotThreadSafe. Then, try to figure out how to stop using one of those. The libraries that have this class may be through transitive dependencies, and so you would also need to identify where those transitive dependencies came from. This will be painful, which is why that I am hoping that newer versions of Android Studio will be more helpful here.

这篇关于添加依赖项后无法合并dex的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆