Multiple dex reference error

Hi!

When i add Push Notifications to my app, i get an error on Android (iOS works perfectly):

Cause: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/iid/zzc;
    UNEXPECTED TOP-LEVEL EXCEPTION:
    com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/iid/zzc;
        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)

I’ve seen the solutions proposed here and here. but it don’t work.

This is the line i’m using

[Require("Gradle.Dependency.Compile", "com.google.android.gms:play-services-ads:11.0.0")]

These options doesn’t work

[Require("Gradle.Dependency","compile('com.google.android.gms:play-services-ads:11.0.0') { exclude module: 'google-android-gms-iid' }")]
[Require("Gradle.Dependency","compile('com.google.android.gms:play-services-ads:11.0.0') { exclude module: 'google-android-gms' }")]
[Require("Gradle.Dependency","compile('com.google.android.gms:play-services-ads:11.0.0') { exclude module: 'com.google.android.gms' }")]
[Require("Gradle.Dependency","compile('com.google.android.gms:play-services-ads:11.0.0') { exclude module: 'com.google.android.gms.iid' }")]

Any idea what is the package name i should put on the exclude module?

Thanks

John

1 Like

Hi!

The code is on this project is on GitHub if anyone want to try it and suggest a fix. By the way, it’s the official release f the DoubleClick SDK for Fuse Tools

I hope you use if you need it

John

Thanks John. Multi-dex support is on the todo list for Fuse so stay tuned for that. Part of that process is updating the build tools and so we will need to do a lot of internal testing to make sure we don’t ship any regressions.

Great news!!! Thanks Chris!

Hi! I found how you can try to fix this error. When you get the multiple dex error, find the build.gradle file located at build/Android/Debug/app.

On my case it looks like this

dependencies {
    compile fileTree(dir: 'src/main/libs', include: ['*.jar'])
    compile 'com.android.support:support-v4:23.4.0'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.android.support:design:23.4.0'
//#if #(Gradle.Dependency.Compile:IsRequired)
    compile 'com.drewnoakes:metadata-extractor:2.10.1'
compile 'com.google.android.gms:play-services-gcm:9.2.0'
//#endif
//#if #(Gradle.Dependency:IsRequired)
    compile('com.google.android.gms:play-services-ads:11.0.0') { exclude module: 'google-android-gms-iid' }
compile('com.facebook.android:facebook-android-sdk:4.8.+') { exclude module: 'support-v4' }
//#endif
}

I notice that a previous line references the com.google.android.gms package, but using a different version. I was trying to use the version 11, and it’s referencing the 9.2. So i changed this line:

[Require("Gradle.Dependency.Compile", "com.google.android.gms:play-services-ads:11.0.0")]

to

[Require("Gradle.Dependency.Compile", "com.google.android.gms:play-services-ads:9.2.0")]

And voila! It works.

So, if you get this error, try to find the package that is generating conflict and try to reference the same version on all places.

I hope it will be useful for someone that get the same error.

Regards

Jonatan

Great work again John. hopefully this will help folks until we can get the official feature shipped.

Hi,

I am integrating Mapbox and FIrebase with Fusetools. And I need support for MultiDex. so is Multidex support is still pending or fixed?

1 Like