1

Error:Error converting bytecode to dex: Cause: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzbqy;

this error came in my android chat app, i found couple answers here but it couldn't solve my problem. i am using Firebase for my project, i have successfully done authentication of my user and wanted to app their photo and username in realtime database but this error is preventing further development. what am i doing wrong for this error to come?

build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.example.john.androidchat"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.1.0'
    compile 'com.android.support:design:25.1.0'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'de.hdodenhof:circleimageview:2.1.0'
    compile 'com.google.code.gson:gson:2.8.0'
    compile 'com.synnapps:carouselview:0.0.10'
    compile 'com.google.firebase:firebase-auth:10.2.0'
    compile 'com.google.firebase:firebase-database:10.2.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.1'
    compile 'com.google.firebase:firebase-storage:10.0.1'
    testCompile 'junit:junit:4.12'
}

apply plugin: 'com.google.gms.google-services'
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
subas khanal
  • 9
  • 1
  • 7
  • 1
    show `build.gradle` – IntelliJ Amiya Mar 22 '17 at 06:26
  • apply plugin: 'com.android.application'android { compileSdkVersion 25 buildToolsVersion "25.0.2" defaultConfig { applicationId "com.example.john.androidchat" minSdkVersion 16 targetSdkVersion 25 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } – subas khanal Mar 22 '17 at 06:31
  • compile 'com.android.support:appcompat-v7:25.1.0' compile 'com.android.support:design:25.1.0' compile 'com.github.bumptech.glide:glide:3.7.0' compile 'de.hdodenhof:circleimageview:2.1.0' compile 'com.google.code.gson:gson:2.8.0' compile 'com.synnapps:carouselview:0.0.10' compile 'com.google.firebase:firebase-auth:10.2.0' compile 'com.google.firebase:firebase-database:10.2.0' compile 'com.android.support.constraint:constraint-layout:1.0.1' compile 'com.google.firebase:firebase-storage:10.0.1' testCompile 'junit:junit:4.12' – subas khanal Mar 22 '17 at 06:33
  • add this question section . – IntelliJ Amiya Mar 22 '17 at 06:34
  • set `firebase-storage:10.2.0` – IntelliJ Amiya Mar 22 '17 at 06:51
  • I had the same problem but it solve with this: https://stackoverflow.com/a/46446772/1498586 – Mahdi Sep 27 '17 at 11:31

3 Answers3

1

Enable Multidex in your app and increase heap size.

e.g build.gradle

android {

compileSdkVersion 23
buildToolsVersion "24.0.2"
defaultConfig {

    minSdkVersion 16
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"

    multiDexEnabled true
}

dexOptions {
    javaMaxHeapSize "4g"
}

dependencies {

compile 'com.android.support:multidex:1.0.1'

}

Write below code inside Application tag in your Manifest

android:name="android.support.multidex.MultiDexApplication"

1

Make sure that you list your firebase dependencies first as such:

app/build.gradle

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'

    compile 'com.google.firebase:firebase-database:11.0.1'
    compile 'com.android.support:appcompat-v7:26.0.0+'
    compile 'com.android.support:design:26.0.0+'

    // Displaying images
    compile 'com.github.bumptech.glide:glide:3.7.0'
}
apply plugin: 'com.google.gms.google-services'
Community
  • 1
  • 1
mvbrenes
  • 517
  • 5
  • 9
1

For those who with matching dependency versions and still receiving this error:

Firebase Android SDKs now have independent version numbers, allowing for more frequent, flexible updates.

Update all your Firebase dependencies to the latest version (as of 2 May 2018):

 Firebase Core          com.google.firebase:firebase-core:15.0.2
    Ads                 com.google.firebase:firebase-ads:15.0.0
  Analytics             com.google.firebase:firebase-analytics:15.0.2
 App Indexing           com.google.firebase:firebase-appindexing:15.0.0
 Authentication         com.google.firebase:firebase-auth:15.1.0
Cloud Firestore         com.google.firebase:firebase-firestore:16.0.0
Cloud Functions         com.google.firebase:firebase-functions:15.0.0
Cloud Messaging         com.google.firebase:firebase-messaging:15.0.2
Cloud Storage           com.google.firebase:firebase-storage:15.0.2
Crash Reporting         com.google.firebase:firebase-crash:15.0.2
Crashlytics             com.crashlytics.sdk.android:crashlytics:2.9.1
Invites                 com.google.firebase:firebase-invites:15.0.2
Performance Monitoring  com.google.firebase:firebase-perf:15.1.0
Realtime Database       com.google.firebase:firebase-database:15.0.0
Remote Config           com.google.firebase:firebase-config:15.0.2

Release note: https://firebase.google.com/support/release-notes/android

Davis
  • 85
  • 2
  • 8