镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

com.android.dex.DexException: Multiple dex files define in android app #299

Closed

Description

@BlakeRxxk

After adding react-native-firestack I've got this error

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzble;
	at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
	at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
	at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
	at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
	at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
	at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502)
	at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
	at com.android.dx.command.dexer.Main.run(Main.java:277)
	at com.android.dx.command.dexer.Main.main(Main.java:245)
	at com.android.dx.command.Main.main(Main.java:106)


:app:transformClassesWithDexForDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2

RN: 0.41.2

Any ideas?

Thanks

Activity

  1. oiaren commented on Mar 4, 2017

    @oiaren

    I just had this error, this is how I managed to fix it.

    Change
    compile project(':react-native-firestack')
    To
    compile(project(':react-native-firestack')){ exclude group: 'com.google.android.gms' }

    On your android/app/build.gradle file.

    Hope it works for you!

  2. BlakeRxxk commented on Mar 5, 2017

    @BlakeRxxk
    Author

    @GDuarteL, thank you! work like a charm!

  3. maggialejandro commented on Mar 16, 2017

    @maggialejandro

    I'm facing the same issue here,
    these are my dependencies in app/build.gradle

    dependencies {
        compile(project(':react-native-firestack')){
            exclude group: "com.google.android.gms" // very important
        }
        compile project(':react-native-facebook-login')
        compile project(':react-native-vector-icons')
        compile fileTree(dir: "libs", include: ["*.jar"])
        compile "com.android.support:appcompat-v7:23.0.1"
        compile "com.facebook.react:react-native:+"
        compile(project(":react-native-google-signin")){
            exclude group: "com.google.android.gms" // very important
        }
        compile 'com.google.android.gms:play-services-auth:9.2.1' // should be at least 9.0.0
    }
    

    Do you see something that may be causing problems?

  4. jdmunro commented on Mar 28, 2017

    @jdmunro

    @maggialejandro I had this issue too even after the fixes. I was able to solve it by loosening the dependencies in the gradle file for firestack as mentioned in #290. I don't know if there's any intention of merging this.

  5. rahulsharma29 commented on Jun 12, 2017

    @rahulsharma29

    I am also getting the same error

    Error:Error converting bytecode to dex:
    Cause: com.android.dex.DexException: Multiple dex files define Lai/api/AIListener;
    Error:Execution failed for task ':apiAISampleApp:transformClassesWithDexForDebug'.

    com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Error while executing java process with main class com.android.dx.command.Main with arguments {--dex --num-threads=4 --output D:\ISM_MOBILE_DEV\apiai-android-client-master\apiAISampleApp\build\intermediates\transforms\dex\debug\folders\1000\1f\main D:\ISM_MOBILE_DEV\apiai-android-client-master\apiAISampleApp\build\intermediates\pre-dexed\debug\classes_1e235a558aa69bbce7a7b3e6e87a439f2e4f2b4c.jar D:\ISM_MOBILE_DEV\apiai-android-client-master\apiAISampleApp\build\intermediates\pre-dexed\debug\log4j-api-2.2_257da8b322db4af95fe5483ebcd65cbd8dd33a69.jar D:\ISM_MOBILE_DEV\apiai-android-client-master\apiAISampleApp\build\intermediates\pre-dexed\debug\classes_b2ddc253f20ae42fbb2a453f8ef0cfc7f30de781.jar D:\ISM_MOBILE_DEV\apiai-android-client-master\apiAISampleApp\build\intermediates\pre-dexed\debug\classes_0bffca0f901190ce1fdc4c15fc75b5cff26a232c.jar D:\ISM_MOBILE_DEV\apiai-android-client-master\apiAISampleApp\build\intermediates\pre-dexed\debug\debug_f562e10b247e80ddabd0b312a3dc12908998b2a7.jar D:\ISM_MOBILE_DEV\apiai-android-client-master\apiAISampleApp\build\intermediates\pre-dexed\debug\classes_ec864a258c34ddce59b4a1a8d1cf1b04e5e540f5.jar D:\ISM_MOBILE_DEV\apiai-android-client-master\apiAISampleApp\build\intermediates\pre-dexed\debug\support-annotations-23.2.1_a87e9adedbde6e112b2a567abd211d4ea3779970.jar D:\ISM_MOBILE_DEV\apiai-android-client-master\apiAISampleApp\build\intermediates\pre-dexed\debug\libai-1.4.8_dd6d67e9a5b1efd7e19666bbaf1ed4056b489338.jar D:\ISM_MOBILE_DEV\apiai-android-client-master\apiAISampleApp\build\intermediates\pre-dexed\debug\internal_impl-23.2.1_ff20ed901b634ddffe70b35e0580ea5f06140f06.jar D:\ISM_MOBILE_DEV\apiai-android-client-master\apiAISampleApp\build\intermediates\pre-dexed\debug\classes_3eaf570f457d48c72f235dcbe922c96ff4be9911.jar D:\ISM_MOBILE_DEV\apiai-android-client-master\apiAISampleApp\build\intermediates\pre-dexed\debug\gson-2.3.1_52723360fde34a10d58b51a1f06333e71be71f3c.jar D:\ISM_MOBILE_DEV\apiai-android-client-master\apiAISampleApp\build\intermediates\pre-dexed\debug\log4j-core-2.2_83ceb67f2bdaf1c737772d11d33edb0ba903cd32.jar D:\ISM_MOBILE_DEV\apiai-android-client-master\apiAISampleApp\build\intermediates\pre-dexed\debug\classes_46abb2498fd8aa2de679175d6e80ae0b0c50a219.jar D:\ISM_MOBILE_DEV\apiai-android-client-master\apiAISampleApp\build\intermediates\pre-dexed\debug\classes_ed14469add15715f8077f02056cb66b4d23c2ec2.jar D:\ISM_MOBILE_DEV\apiai-android-client-master\apiAISampleApp\build\intermediates\pre-dexed\debug\commons-io-2.4_b2955a73e8fdec69863902c786dced8321b28c5c.jar}

    My build.griddle is as fallows

    apply plugin: 'com.android.application'
    apply plugin: 'com.neenbedankt.android-apt'

    android {
    compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
    buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
    defaultConfig {
    applicationId 'ai.api.sample'
    minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION)
    targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
    versionCode Integer.parseInt(project.VERSION_CODE)
    versionName project.VERSION_NAME
    }
    buildTypes {
    release {
    //proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
    }
    productFlavors {
    }
    packagingOptions {
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/NOTICE.txt'
    exclude 'LICENSE.txt'
    }
    }

    repositories {
    mavenLocal()
    mavenCentral()
    maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
    }

    dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.2.1'
    compile 'com.google.code.gson:gson:2.3.1'
    compile 'commons-io:commons-io:2.4'
    compile 'ai.api:libai:1.4.8'
    compile 'ai.api:sdk:2.0.5@aar'
    // compile 'ai.api:sdk:2.0.4@aar'
    // this line is for testing purposes
    compile project(':ailib')
    }

  6. Opriday commented on Nov 13, 2017

    @Opriday

    Go the Gradle and move cursor on each library if there is updated version available then update the library then sync the Gradle. Actually I was up to this problem for 2 days I tried every method but did not solve it. then I updated the library, sync the gradle and run agian. it worked for me.

  7. kaxhiftaj-zz commented on Dec 13, 2017

    @kaxhiftaj-zz

    @Opriday yes this worked for me. Thanks

  8. firedancerx commented on Dec 26, 2017

    @firedancerx

    Hi guys,

    I have this combination of dependencies. Does anyone know which one is to be changed, and to what? The bold lines are the ones with problems.

    Thanks

    dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    > implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    > implementation 'com.google.firebase:firebase-core: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'
    compile 'com.android.support:design:26.1.0'
    compile 'com.firebaseui:firebase-ui:0.6.0'
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions