Reputation: 596
After project into two libraries module and one app module Android Studio is unable to build Apk but when I build project into real device into or emulator it work perfectly
this is the full stack error which I've got in Messages Tab
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
com.android.build.api.transform.TransformException: Error while generating the main dex list.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 1m 58s
this is the Gradle for app module
apply plugin: 'com.android.application'
apply plugin: 'org.jetbrains.kotlin.android.extensions'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
signingConfigs {
config {
storeFile file('E:/***.jks')
}
}
compileSdkVersion 27
dataBinding {
enabled = true
}
androidExtensions {
experimental = true
}
defaultConfig {
applicationId "com.**.**"
minSdkVersion 15
targetSdkVersion 27
versionCode 307
versionName "V 3.0.7"
multiDexEnabled true
javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath true
}
}
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
packagingOptions {
exclude 'META-INF/LGPL2.1'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
zipAlignEnabled true
}
debug {
debuggable true
minifyEnabled false
testCoverageEnabled true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
testOptions {
unitTests {
includeAndroidResources = true
}
unitTests.returnDefaultValues = true
}
}
dependencies {
androidTestCompile 'junit:junit:4.12'
androidTestCompile 'org.mockito:mockito-core:1.10.19'
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.10.19'
testCompile 'org.powermock:powermock-module-junit4:1.6.4'
//test
androidTestCompile 'com.android.support.test:runner:1.0.2'
androidTestCompile 'com.android.support.test:rules:1.0.2'
// Optional -- Hamcrest library
androidTestCompile 'org.hamcrest:hamcrest-library:1.3'
// Optional -- UI testing with Espresso
androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation files('libs/zip4j_1.3.2.jar')
implementation project (':lib1')
implementation project (':lib2')
implementation project(':PersianDateTimePicker')
implementation project(':crystalrangeseekbar-1.1.3')
implementation files('libs/easywsdl/ksoap2-android-assembly-3.6.2-jar-with-dependencies.jar')
implementation "com.android.support:multidex:$multi_dex_version"
implementation "com.android.support:support-v4:$support_version"
implementation "com.android.support:appcompat-v7:$support_version"
implementation "com.android.support:design:$support_version"
implementation "com.android.support:cardview-v7:$support_version"
implementation "com.android.support:recyclerview-v7:$support_version"
implementation "com.android.support:support-v13:$support_version"
implementation "com.android.support:preference-v7:$support_version"
implementation "com.android.support:support-vector-drawable:$support_version"
implementation "com.android.support:animated-vector-drawable:$support_version"
implementation "com.android.support:mediarouter-v7:$support_version"
implementation 'com.esri.arcgis.android:arcgis-android:10.2.9'
implementation 'com.nononsenseapps:filepicker:2.4.2'
implementation 'com.github.bmelnychuk:atv:1.2.9'
implementation 'com.github.johnkil.print:print:1.3.1'
implementation 'com.larswerkman:HoloColorPicker:1.5'
implementation 'com.gordonwong:material-sheet-fab:1.2.1'
implementation 'com.github.sevar83:indeterminate-checkbox:1.0.5@aar'
implementation 'com.github.clans:fab:1.6.4'
implementation 'ch.acra:acra:4.9.2'
implementation 'net.time4j:time4j-android:3.32-2017b'
implementation 'com.ibm.icu:icu4j:57.1'
implementation 'lib.kashif:folderpicker:2.2'
implementation 'com.davemorrissey.labs:subsampling-scale-image-view:3.6.0'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.google.android.gms:play-services-location:15.0.1'
implementation 'org.apache.httpcomponents:httpcore:4.4.7'
implementation('com.github.bumptech.glide:glide:4.6.1') {
exclude group: "com.android.support"
}
annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'
implementation 'com.github.lecho:hellocharts-android:v1.5.8'
implementation 'com.wang.avi:library:2.1.3'
implementation 'com.github.florent37:viewanimator:1.0.5'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "org.jetbrains.anko:anko-sqlite:$anko_version"
implementation "io.reactivex.rxjava2:rxjava:$rxjava2_version"
implementation "io.reactivex.rxjava2:rxandroid:$rxandroid_version"
implementation "com.google.dagger:dagger:$dagger"
implementation "com.google.dagger:dagger-android:$dagger"
implementation "com.google.dagger:dagger-android-support:$dagger"
annotationProcessor "com.google.dagger:dagger-compiler:$dagger"
annotationProcessor "com.google.dagger:dagger-android-processor:$dagger"
implementation "android.arch.persistence.room:runtime:$archRoomVersion"
annotationProcessor "android.arch.persistence.room:compiler:$archRoomVersion"
implementation 'android.arch.persistence.room:rxjava2:1.1.1'
implementation "android.arch.lifecycle:extensions:$lifecycle_version"
implementation "android.arch.lifecycle:viewmodel:$lifecycle_version"
implementation "android.arch.lifecycle:livedata:$lifecycle_version"
implementation "android.arch.lifecycle:runtime:$lifecycle_version"
annotationProcessor "android.arch.lifecycle:compiler:$lifecycle_version"
implementation "android.arch.lifecycle:common-java8:$lifecycle_version"
implementation "android.arch.lifecycle:reactivestreams:$lifecycle_version"
testImplementation "android.arch.core:core-testing:$lifecycle_version"
androidTestImplementation 'android.arch.core:core-testing:1.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.github.angads25:filepicker:1.1.1'
implementation 'com.github.nekocode:Badge:2.0'
implementation files('libs/gt-shapefile-2.7.0.jar')
implementation files('libs/gt-metadata-2.7.0.jar')
}
and the Gradle file for lib1 library module
apply plugin: 'com.android.library'
apply plugin: 'org.jetbrains.kotlin.android.extensions'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
signingConfigs {
config {
storeFile file('E:/**.jks')
}
}
compileSdkVersion 27
dataBinding {
enabled = true
}
defaultConfig {
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
zipAlignEnabled true
}
debug {
debuggable true
minifyEnabled false
testCoverageEnabled false
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
androidTestCompile 'junit:junit:4.12'
androidTestCompile 'org.mockito:mockito-core:1.10.19'
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.10.19'
testCompile 'org.powermock:powermock-module-junit4:1.6.4'
implementation project(':lib2')
//test
androidTestCompile 'com.android.support.test:runner:1.0.2'
androidTestCompile 'com.android.support.test:rules:1.0.2'
// Optional -- Hamcrest library
androidTestCompile 'org.hamcrest:hamcrest-library:1.3'
// Optional -- UI testing with Espresso
androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation project(':PersianDateTimePicker')
implementation project(':crystalrangeseekbar-1.1.3')
implementation "com.android.support:support-v4:$support_version"
implementation "com.android.support:appcompat-v7:$support_version"
implementation "com.android.support:design:$support_version"
implementation "com.android.support:cardview-v7:$support_version"
implementation "com.android.support:recyclerview-v7:$support_version"
implementation "com.android.support:support-v13:$support_version"
implementation "com.android.support:preference-v7:$support_version"
implementation "com.android.support:support-vector-drawable:$support_version"
implementation "com.android.support:animated-vector-drawable:$support_version"
implementation "com.android.support:mediarouter-v7:$support_version"
implementation 'com.esri.arcgis.android:arcgis-android:10.2.9'
implementation 'com.larswerkman:HoloColorPicker:1.5'
implementation 'ch.acra:acra:4.9.2'
implementation 'net.time4j:time4j-android:3.32-2017b'
implementation 'com.ibm.icu:icu4j:57.1'
implementation 'lib.kashif:folderpicker:2.2'
implementation 'com.davemorrissey.labs:subsampling-scale-image-view:3.6.0'
implementation('com.github.bumptech.glide:glide:4.6.1') {
exclude group: "com.android.support"
}
annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'
implementation 'com.github.lecho:hellocharts-android:v1.5.8'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "android.arch.persistence.room:runtime:$archRoomVersion"
annotationProcessor "android.arch.persistence.room:compiler:$archRoomVersion"
implementation "android.arch.lifecycle:extensions:$lifecycle_version"
implementation "android.arch.lifecycle:viewmodel:$lifecycle_version"
implementation "android.arch.lifecycle:livedata:$lifecycle_version"
implementation "android.arch.lifecycle:runtime:$lifecycle_version"
annotationProcessor "android.arch.lifecycle:compiler:$lifecycle_version"
implementation "android.arch.lifecycle:common-java8:$lifecycle_version"
implementation "android.arch.lifecycle:reactivestreams:$lifecycle_version"
testImplementation "android.arch.core:core-testing:$lifecycle_version"
annotationProcessor 'android.arch.core:core-testing:1.1.1'
implementation 'com.github.angads25:filepicker:1.1.1'
}
Upvotes: 2
Views: 8569
Reputation: 596
I got the error and this was because of having two same classes in two modules. while building Apk all classes should be written to main dex list file and if there is a duplicate class name in it, it fails.
The way I found the duplicate class name was by using --stacktrace in command line options which could be reached by
file > setting > build,execution,deployment > compiler
Upvotes: 7