I ran into a really silly issue. I can't assemble my project.
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:
Execution failed for task ':app:transformDexArchiveWithDexMergerForDebug'. com.android.build.api.transform.TransformException: com.android.dex.DexException: Multiple dex files define Lorg/apache/commons/io/IOUtils;
My dependencies tree is the following:
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
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'
}
:DatabaseManagment
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 (root project)
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')
}
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!