多个dex文件定义了Lorg

多个dex文件定义了Lorg

本文介绍了多个dex文件定义了Lorg/apache/commons/io/IOUtils;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个非常愚蠢的问题.我无法组装我的项目.

I ran into a really silly issue.I can't assemble my project.

我创建了单个项目,例如数据库管理,用于api,自定义布局等.现在,我尝试将所有这些项目组合为一个,以构建单个应用程序.

I created single projects for e.g. database managment, for an api, custom layouts, etc. Now I am trying to combine all of these projects into one, to build a single application.

但是不幸的是,它并没有像我收到此错误那样起作用:

But unfortunaley it does not work as excpected as I am getting this error:

我的依赖关系树如下:

6.0.2 (*)
|    |    +--- com.android.support:support-core-utils:26.0.2
|    |    |    +--- com.android.support:support-annotations:26.0.2
|    |    |    \--- com.android.support:support-compat:26.0.2 (*)
|    |    +--- com.android.support:support-core-ui:26.0.2
|    |    |    +--- com.android.support:support-annotations:26.0.2
|    |    |    \--- com.android.support:support-compat:26.0.2 (*)
|    |    \--- com.android.support:support-fragment:26.0.2
|    |         +--- com.android.support:support-compat:26.0.2 (*)
|    |         +--- com.android.support:support-core-ui:26.0.2 (*)
|    |         \--- com.android.support:support-core-utils:26.0.2 (*)
|    +--- com.android.support:support-vector-drawable:26.0.2
|    |    +--- com.android.support:support-annotations:26.0.2
|    |    \--- com.android.support:support-compat:26.0.2 (*)
|    \--- com.android.support:animated-vector-drawable:26.0.2
|         +--- com.android.support:support-vector-drawable:26.0.2 (*)
|         \--- com.android.support:support-core-ui:26.0.2 (*)
+--- com.android.support:multidex:1.0.2
+--- com.github.jetradarmobile:multibackstack:1.2.1
|    \--- com.android.support:appcompat-v7:25.3.1 -> 26.0.2 (*)
+--- com.ashokvarma.android:bottom-navigation-bar:2.0.2
|    +--- com.android.support:appcompat-v7:25.3.1 -> 26.0.2 (*)
|    \--- com.android.support:design:25.3.1
|         +--- com.android.support:support-v4:25.3.1 -> 26.0.2 (*)
|         +--- com.android.support:appcompat-v7:25.3.1 -> 26.0.2 (*)
|         +--- com.android.support:recyclerview-v7:25.3.1
|         |    +--- com.android.support:support-annotations:25.3.1 -> 26.0.2
|         |    +--- com.android.support:support-compat:25.3.1 -> 26.0.2 (*)
|         |    \--- com.android.support:support-core-ui:25.3.1 -> 26.0.2 (*)
|         \--- com.android.support:transition:25.3.1
|              +--- com.android.support:support-annotations:25.3.1 -> 26.0.2
|              \--- com.android.support:support-v4:25.3.1 -> 26.0.2 (*)
+--- com.github.bumptech.glide:glide:4.0.0
|    +--- com.github.bumptech.glide:gifdecoder:4.0.0
|    |    \--- com.android.support:support-annotations:25.3.1 -> 26.0.2
|    +--- com.github.bumptech.glide:disklrucache:4.0.0
|    \--- com.github.bumptech.glide:annotations:4.0.0
+--- com.android.support.constraint:constraint-layout:1.1.0-beta1
|    \--- com.android.support.constraint:constraint-layout-solver:1.1.0-beta1
+--- com.wdullaer:swipeactionadapter:2.0.0
|    \--- com.android.support:support-annotations:23.1.0 -> 26.0.2
+--- project :onboarder
|    +--- com.android.support.constraint:constraint-layout:1.0.2 -> 1.1.0-beta1 (*)
|    +--- com.android.support:appcompat-v7:26.0.2 (*)
|    +--- com.android.support:cardview-v7:26.0.2
|    |    \--- com.android.support:support-annotations:26.0.2
|    \--- com.android.support:support-v4:26.0.2 (*)
+--- project :DatabaseManagement
|    +--- io.realm:realm-android-library:3.7.2
|    |    +--- com.google.code.findbugs:jsr305:3.0.2
|    |    +--- com.getkeepsafe.relinker:relinker:1.2.2
|    |    \--- io.realm:realm-annotations:3.7.2
|    \--- io.realm:realm-annotations:3.7.2
\--- project :api
     +--- com.google.code.gson:gson:2.8.1
     +--- com.google.apis:google-api-services-youtube:v3-rev44-1.14.1-beta
     |    \--- com.google.api-client:google-api-client:1.14.1-beta
     |         \--- com.google.oauth-client:google-oauth-client:1.14.1-beta
     |              +--- com.google.http-client:google-http-client:1.14.1-beta
     |              |    +--- com.google.code.findbugs:jsr305:1.3.9 -> 3.0.2
     |              |    +--- org.apache.httpcomponents:httpclient:4.0.1
     |              |    |    +--- org.apache.httpcomponents:httpcore:4.0.1
     |              |    |    +--- commons-logging:commons-logging:1.1.1
     |              |    |    \--- commons-codec:commons-codec:1.3
     |              |    \--- xpp3:xpp3:1.1.4c
     |              \--- com.google.code.findbugs:jsr305:1.3.9 -> 3.0.2
     +--- io.reactivex.rxjava2:rxandroid:2.0.1
     |    \--- io.reactivex.rxjava2:rxjava:2.0.1 -> 2.1.3
     |         \--- org.reactivestreams:reactive-streams:1.0.1
     +--- io.reactivex.rxjava2:rxjava:2.1.3 (*)
     \--- org.apache.commons:commons-io:1.3.2
          \--- commons-io:commons-io:1.3.2

这是我在项目中获得的模块:

:TOPLEVEL

Here are the modules I got in my project:

:TOPLEVEL

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0-beta5'
        classpath "io.realm:realm-gradle-plugin:3.7.2"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven { url "https://jitpack.io" }
        maven { url 'https://maven.google.com' }
        maven { url 'https://oss.jfrog.org/libs-snapshot' }
    }

    project.ext {
        minSdk=14
        targetSdk=26
        buildVersion="26.0.1"
        compileSdk=26
        supportLibraryVersion="26.0.2"
        set('supportLibraryVersion',supportLibraryVersion)
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

:api

dependencies {
    implementation 'org.jsoup:jsoup:1.10.3'
    implementation ('com.google.http-client:google-http-client-jackson2:1.22.0')
    api 'com.google.code.gson:gson:2.8.1'
    api ('com.google.apis:google-api-services-youtube:v3-rev44-1.14.1-beta')
    api 'io.reactivex.rxjava2:rxandroid:2.0.1'
    api 'io.reactivex.rxjava2:rxjava:2.1.3'
}

:数据库管理

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation "com.android.support:appcompat-v7:${supportLibraryVersion}"
    implementation project(':api')
    implementation 'org.apache.commons:commons-io:1.3.2'
}

:onboarder

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile "com.android.support:appcompat-v7:${supportLibraryVersion}"
    compile "com.android.support:cardview-v7:${supportLibraryVersion}"
    compile "com.android.support:support-v4:${supportLibraryVersion}"
}

:app(根项目)

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    /** Android/Google Support Libraries **/
    implementation "com.android.support:appcompat-v7:${supportLibraryVersion}"
    implementation 'com.android.support:multidex:1.0.2'
    /** UI dependencies **/
    implementation 'com.github.jetradarmobile:multibackstack:1.2.1'
    //has dependencies on old appcompat version
    implementation 'com.ashokvarma.android:bottom-navigation-bar:2.0.2'
    //has dependencies on old appcompat version
    implementation 'com.github.bumptech.glide:glide:4.0.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0-beta1'
    implementation 'com.wdullaer:swipeactionadapter:2.0.0'
    implementation project(':onboarder')
    /** Techniqual implementations */
    implementation project(':DatabaseManagement')
    implementation project(':api')
}

尝试过的解决方案:
在过去的3个小时里,我疯狂地寻找解决方案,但没有找到任何可行的方法.从依赖关系树中我都看不到发生了对commons-io的双重引用,这很明显地导致了此错误.
这里不是问题,如果没有multidex,Multidex也无法组装.

我正在使用Android Studio 3 Beta 5

Tried Solutions:
The past 3 hours I went crazy finding a solution but nothing I have found worked. Neither I can see from the dependency tree where a double reference to commons-io is happening which obiously is causing this error.
Multidex isn't the problem here, without multidex it also fails to assemble.

I am working with Android Studio 3 Beta 5

可能我错过了明显的机会.
非常感谢您的帮助!

Propably, I am missing out to see the obvious.
I really appreciate your help in advance!

推荐答案

问题已解决!这是一个错误的公地依附.失败的原因可以在这里找到:

Problem solved!It was a wrong commons-io dependecy.The reason for this failure can be found here: What is the difference between maven dependencies org.apache.commons:commons-io and commons-io:commons-io?

只需更换

这篇关于多个dex文件定义了Lorg/apache/commons/io/IOUtils;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 05:32