Reputation: 60
I am getting an error when I try to install my Application on my Phone. I tried to clean the project and then make it afterwards, but it is not working. When I only rebuild the project, it is working. This is the error I get :
Information:Gradle tasks [:app:assembleDebug]
Error:Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/auth/api/signin/zzc;
Error:com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/auth/api/signin/zzc;
Error: at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:661)
Error: at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:616)
Error: at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:598)
Error: at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
Error: at com.android.dx.merge.DexMerger.merge(DexMerger.java:198)
Error: at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:61)
Error: at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:36)
Error: at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)
Error: at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
Error: at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
Error: at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
Error: at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Error:Execution failed for task ':app:transformDexArchiveWithDexMergerForDebug'.
> com.android.build.api.transform.TransformException: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/auth/api/signin/zzc;
Information:BUILD FAILED in 10s
Information:15 errors
Information:0 warnings
Information:See complete output in console
And this is my build.gradle (Module: app ) file:
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "my.application.path"
minSdkVersion 21
targetSdkVersion 25
versionCode 2
versionName "2.6.1"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
lintOptions { checkReleaseBuilds false }
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.0', {
exclude group: 'com.android.support', module: 'support-annotations'
})
//noinspection GradleCompatible
compile 'com.android.support:appcompat-v7:25.4.0'
compile 'com.android.support:design:25.4.0'
compile 'com.android.support:recyclerview-v7:25.4.0'
compile 'com.sloydev:collapsingavatartoolbar:1.0.0'
compile 'com.android.support:cardview-v7:25.4.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.github.bumptech.glide:glide:3.5.2'
annotationProcessor 'com.github.bumptech.glide:compiler:4.1.1'
compile 'com.google.firebase:firebase-database:11.0.2'
compile 'com.google.firebase:firebase-storage:11.0.2'
compile 'com.google.firebase:firebase-crash:11.0.2'
compile 'com.google.firebase:firebase-messaging:11.0.2'
compile 'com.google.firebase:firebase-core:11.0.2'
compile 'com.google.firebase:firebase-auth:11.0.2'
compile "com.google.android.gms:play-services-places:11.0.2"
compile "me.leolin:ShortcutBadger:1.1.18@aar"
compile 'com.firebaseui:firebase-ui:1.1.1'
compile 'com.theartofdev.edmodo:android-image-cropper:2.4.+'
testCompile 'junit:junit:4.12'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.github.karanchuri:PermissionManager:0.1.0'
compile 'com.squareup.okhttp:okhttp:2.5.0'
compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
transitive = true;
}
}
apply plugin: 'com.google.gms.google-services'
And this is my build.gradle (Project: projectname)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
maven {url 'https://maven.fabric.io/public'}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-beta2'
classpath 'com.google.gms:google-services:3.1.0'
classpath 'io.fabric.tools:gradle:1.24.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://maven.fabric.io/public' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
It started to happen when I had to update the google play services. But I do not know what I should change.
Upvotes: 3
Views: 3773
Reputation: 28835
In my case there were two similar files in Java and Kotlin (for instance, "SomeView.java" and "SomeView.kt").
Upvotes: 0
Reputation: 17651
Check for duplicate libraries which are referring to the same jar, similar to what happened in this SO post.
You can also read from this post:
Your problem i believe is that wherever you are linking the Library to your Main Project you have the same dependencies between the two for your support library and annotations.
If you have the library project as a dependency in your application you will only need the dependency to be placed in the library dependencies closure.
The issue is that you have two dex files because there are two Files with the same name because the overlap in files with your dependencies.
Upvotes: 4