Reputation: 819
I am developing an android app and gradle build was working fine but now when I build my android project, the gradle build failed and shows following error
Error converting bytecode to dex: Cause: com.android.dex.DexException: Multiple dex files define Landroid/arch/core/internal/SafeIterableMap$Entry; Message{kind=ERROR, text=Error converting bytecode to dex: Cause: com.android.dex.DexException: Multiple dex files define Landroid/arch/core/internal/SafeIterableMap$Entry;, sources=[Unknown source file], original message=UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define Landroid/arch/core/internal/SafeIterableMap$Entry; , tool name=Optional.of(Dex)}
Note:
I have already added multiDexEnabled true
in my build.gradle(app) and I have also cleaned and rebuild the project
I am using Android studio 3.1
My build.gradle(app) is below
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
multiDexEnabled true
applicationId "atnd.mdadil2019.myprojectname"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.google.firebase:firebase-auth:11.8.0'
implementation 'com.google.firebase:firebase-database:11.8.0'
implementation 'com.google.firebase:firebase-storage:11.8.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
//3rd party libraries
implementation 'cn.pedant.sweetalert:library:1.3'
implementation 'com.github.jlmd:AnimatedCircleLoadingView:1.1.5@aar'
implementation 'com.google.android.gms:play-services-places:11.8.0'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'android.arch.persistence.room:runtime:1.0.0-alpha1';
annotationProcessor 'android.arch.persistence.room:compiler:1.0.0-alpha1';
implementation 'com.google.android.gms:play-services-location:11.8.0'
}
apply plugin: 'com.google.gms.google-services'
My build.gradle(Project) is below
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.2.1'
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven {
url "http://dl.bintray.com/jlmd/maven"
}
maven { url 'https://maven.google.com' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Upvotes: 1
Views: 380
Reputation: 1007369
Your error is that you have 2+ dependencies that declare android.arch.core.internal.SafeIterableMap$Entry
.
First, upgrade your Room dependencies from 1.0.0-alpha1
to 1.0.0
. Room has been out of alpha for several months.
If that does not clear up your problem, you will need to run a Gradle dependency report and find where you are getting 2+ versions of android.arch
libraries, then make sure you are getting the latest versions of those libraries.
Upvotes: 2