Shashi
Shashi

Reputation: 13

Error com.android.dex.DexException: Multiple dex files define Lcom/google/android/libraries/places/internal/dh;

I got this Error:

Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Lcom/google/android/libraries/places/internal/dh;

I tried cleaning and rebuilding the project, but it didn't work. Any help will be appreciated.

Android Studio 3.0.1

Project level build.gradle

buildscript {

    repositories {
        google()
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath 'com.google.gms:google-services:4.2.0'
    }
}

allprojects {

    repositories {
        mavenCentral()
        google()
        jcenter()
        maven { url 'https://jitpack.io'
                }

    }
}

task clean(type: Delete) {

delete rootProject.buildDir

}

App level build.gradle

apply plugin: 'com.android.application'

android {

    compileSdkVersion 27
    buildToolsVersion '27.0.3'
    defaultConfig {
        applicationId "in.mycrony"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 86
        versionName "2.86"
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    dexOptions {
        javaMaxHeapSize "4g"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {

    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.4'
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.github.barteksc:android-pdf-viewer:2.0.3'
    implementation 'com.google.android.libraries.places:places-compat:1.1.0'
    implementation 'com.davemorrissey.labs:subsampling-scale-image-view:3.4.1'
    implementation 'id.zelory:compressor:2.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.squareup.picasso:picasso:2.5.1'
    implementation 'com.theartofdev.edmodo:android-image-cropper:2.4.+'
    implementation 'com.squareup.okhttp3:okhttp:3.7.0'
    implementation 'de.hdodenhof:circleimageview:3.0.0'
    implementation 'com.google.firebase:firebase-database:17.0.0'
    implementation 'com.google.firebase:firebase-auth:17.0.0'
    implementation 'com.google.android.libraries.places:places-compat:1.1.0'
    implementation 'com.google.firebase:firebase-messaging:18.0.0'
    implementation 'com.google.android.libraries.places:places:1.1.0'
    implementation project(':library')

}

apply plugin: 'com.google.gms.google-services'

Library level build.gradle

apply plugin: 'com.android.library'

apply from: "quality.gradle"

group = 'com.github.eggheadgames'

android {

    compileSdkVersion 27
    buildToolsVersion '26.0.2'

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 13
        versionName "1.5.2"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    lintOptions {
        warningsAsErrors true

        disable 'OldTargetApi'
        disable 'GradleDependency'
    }
}

dependencies {


    testImplementation 'org.mockito:mockito-core:1.10.19'

    testImplementation 'org.json:json:20160212'

    implementation 'com.android.support:appcompat-v7:27.1.1'

}

I have tried all the answers given but I am unable to solve this error.

Upvotes: 0

Views: 586

Answers (2)

Shashi
Shashi

Reputation: 13

Finally, I just used implementation 'com.google.android.libraries.places:places:1.0.0' for Place Autocomplete and used the same old 'com.google.android.gms:play-services' dependency for Place Picker.

Upvotes: 0

IntelliJ Amiya
IntelliJ Amiya

Reputation: 75798

Cause: com.android.dex.DexException: Multiple dex files define Lcom/google

You should use one of them

 implementation 'com.google.android.libraries.places:places-compat:1.1.0'
 implementation 'com.google.android.libraries.places:places:1.1.0' //Remove

Then Clean-Rebuild-Run.

Upvotes: 3

Related Questions