react-native-firebase icon indicating copy to clipboard operation
react-native-firebase copied to clipboard

Multiple dex files define Lcom/google/firebase/iid/zzb;

Open BlakeRxxk opened this issue 9 years ago • 12 comments

After adding this package i've got this error

Dex: Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Lcom/google/firebase/iid/zzb;
    UNEXPECTED TOP-LEVEL EXCEPTION:
    com.android.dex.DexException: Multiple dex files define Lcom/google/firebase/iid/zzb;
        at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:579)
        at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:535)
        at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:517)
        at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:164)
        at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
        at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:504)
        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

app/build.gradle

dependencies {
    compile project(':react-native-firebase')
    compile project(':react-native-material-kit')
    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:+"  // From node_modules
    compile project(':react-native-camera')
    compile project(':react-native-fs')
    compile project(':react-native-push-notification')
}

Also I'm trying to exclude group: 'com.google.android.gms' -same error

RN: 0.43.3

Any ideas?

Thanks

BlakeRxxk avatar Apr 12 '17 10:04 BlakeRxxk

Annoyingly this is down to a conflict of versions somewhere. For example react-native-push-notification has compile 'com.google.android.gms:play-services-gcm:+', so you need to exclude that as well. You'll need to go through each package and check for conflicts between them. Our own build.gradle has all sorts excluded all over the place.

Ehesp avatar Apr 12 '17 10:04 Ehesp

RNFirebase uses: me.leolin:ShortcutBadger:1.1.10@aar RNPush-Notifications uses: me.leolin:ShortcutBadger:1.1.8@aar

I'd suggest excluding from both, and then adding yourself afterwards. RNFirebase does handle FCM push messages though, so is the latter needed?

Ehesp avatar Apr 12 '17 11:04 Ehesp

So, i'm tried to exclude play services from react-native-push-notification and get error after app launch firebase error

I'm a little bit confused. Im trying exclude group from both packages

* What went wrong:
Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/google/firebase/iid/zzb;

BlakeRxxk avatar Apr 12 '17 11:04 BlakeRxxk

I got the same conflict with react-native-device-info and solved it with :

    compile (project(':react-native-device-info')) {
        exclude group: "com.google.android.gms"
    }

Patatruffe34 avatar Apr 12 '17 14:04 Patatruffe34

@BlakeRxxk did you manage to get it working? I'm getting the same thing with 'Code 2' and then 'unfortunately my app has stopped'

@BlakeRxxk that's because you're running on GenyMotion emulator - does not have google play services installed on the emulator. See the geny motion instructions for adding play services to the emulator.

Salakar avatar Apr 16 '17 12:04 Salakar

@SamMatthewsIsACommonName code 2 just means it's out of date, update your emulator to the lastest build - or turn the errorOnMissingPlayServices option to false on the firebase.initializeApp(optsHere) bit.

Salakar avatar Apr 16 '17 12:04 Salakar

Hey @Salakar thanks for getting back. Turning the option to false worked thanks! To clarify, when the project requires google play services e.g 10.2.0, does that mean all users would need to have google play services 10.20.0 or higher installed on the phone?

Its the google services that's builtin on the emulator that's the issue e.g. Play Store, just need to get a new emulator image with updated google services on the SDK Manager. It's separate to anything in the gradle files.

Code 2 just means it's slightly out of date and could potentially cause issues if the user doesn't update services on their device. Code 9 in @BlakeRxxk 's case means the device doesn't have it at all - usual for genymotion emulators.

@chrisbianca added an option to automatically prompt the user to update using android's built in method: https://github.com/invertase/react-native-firebase/commit/baa198ea7d4e28d72900ede81f5d5dba8b7d440e - not been released yet though I don't think.

Worth noting this is an android only issue as Firebase requires Google Play Services on the device to work, ios it does not.

Salakar avatar Apr 16 '17 13:04 Salakar

Thank you @Salakar

BlakeRxxk avatar Apr 17 '17 06:04 BlakeRxxk

I had this very problem with react-native-maps. My solution was to apply this.

ancyrweb avatar Oct 03 '17 05:10 ancyrweb

The below is the issue, when i run react-native run-android after configuring firebase to my react-native project. please find the attachments below(for better understanding i have changed the file names here)

android-app-build.gradle.txt android-build.gradle.txt mainApplication.java.txt settings-gradle.txt

Dex: Error converting bytecode to dex: Cause: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzfkt; UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzfkt; at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:591) at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:546) at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:528) at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:164) at com.android.dx.merge.DexMerger.merge(DexMerger.java:188) at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:504) 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: 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 C:\Users\eakhmas\src\ehs-mobile-app\android\app\build\intermediates\transforms\dex\debug\folders\1000\1f\main C:\Users\eakhmas\src\ehs-mobile-app\android\app\build\intermediates\pre-dexed\debug\classes_0558014b1a2499fa62ae2e179d92eedb25a2db34.jar C:\Users\eakhmas\src\ehs-mobile-app\android\app\build\intermediates\pre-dexed\debug\debug_157f80f326c56e04a0ba82aaeee654fcce67b9e2.jar C:\Users\eakhmas\src\ehs-mobile-app\android\app\build\intermediates\pre-dexed\debug\classes_c4d3b679ddf1f7a1b6dd160881c6cd4f3e963961.jar C:\Users\eakhmas\src\ehs-mobile-app\android\app\build\intermediates\pre-dexed\debug\classes_883586b33f8bf3c18dbfbb2d9ac46163b710db23.jar C:\Users\eakhmas\src\ehs-mobile-app\android\app\build\intermediates\pre-dexed\debug\bolts-tasks-1.4.0_79ae474447df465463046cf669d3dcff3fb6bd0c.jar C:\Users\eakhmas\src\ehs-mobile-app\android\app\build\intermediates\pre-dexed\debug\classes_dc55cc6428c7ed95bd4d65e20e8fe3b182c81144.jar C:\Users\eakhmas\src\ehs-mobile-app\android\app\build\intermediates\pre-dexed\debug\classes_85cd5714ecff6e2c64676ff08fd3cc32ecd51dd5.jar C:\Users\eakhmas\src\ehs-mobile-app\android\app\build\intermediates\pre-dexed\debug\classes_7248c61a51477b5b1278913e923ab24b9d918577.jar C:\Users\eakhmas\src\ehs-mobile-app\android\app\build\intermediates\pre-dexed\debug\classes_f9cec181f215a2062f22de310377a4adcb0eb68d.jar C:\Users\eakhmas\src\ehs-mobile-app\android\app\build\intermediates\pre-dexed\debug\javax.inject-1_21946a94be40da79aab1de46e61c1d97e30c5d38.jar C:\Users\eakhmas\src\ehs-mobile-app\android\app\build\intermediates\pre-dexed\debug\classes_8c2e65d49efd954193fd8f3d17b0daa3a9ccb614.jar C:\Users\eakhmas\src\ehs-mobile-app\android\app\build\intermediates\pre-dexed\debug\classes_6a45ee2e6ed53420648ebbf0a53dd95d5bc57353.jar C:\Users\eakhmas\src\ehs-mobile-app\android\app\build\intermediates\pre-dexed\debug\classes_6142895da50162f27d2d0cc624c720ea1e195276.jar C:\Users\eakhmas\src\ehs-mobile-app\android\app\build\intermediates\pre-dexed\debug\infer-annotations-4.0_f815966bc82744c5990edeb11acdadf1edd137ea.jar C:\Users\eakhmas\src\ehs-mobile-app\android\app\build\intermediates\pre-dexed\debug\classes_2c80bfc6a51f9dc06c9167301fc8d03ae9b65597.jar C:\Users\eakhmas\src\ehs-mobile-app\android\app\build\intermediates\pre-dexed\debug\classes_b0a30a3d75094aed0b8f5f2ff187d2ea420d1c2f.jar C:\Users\eakhmas\src\ehs-mobile-app\android\app\build\intermediates\pre-dexed\debug\classes_17a925ca4044eee6b88a24ecf7a26ca20414df4e.jar C:\Users\eakhmas\src\ehs-mobile-app\android\app\build\intermediates\pre-dexed\debug\classes_1b5670d63cafa1e95db68f9187d9e05d7590e607.jar C:\Users\eakhmas\src\ehs-mobile-app\android\app\build\intermediates\pre-dexed\debug\classes_899969e6d099b8ea763ba3808e7a1fd766d2778c.jar C:\Users\eakhmas\src\ehs-mobile-app\android\app\build\intermediates\pre-dexed\debug\classes_b721ca6ca0da6054892672e80934d795fcb4c0d8.jar C:\Users\eakhmas\src\ehs-mobile-app\android\app\build\intermediates\pre-dexed\debug\classes_9be34c38e83c262740ce79e80187e0a97e7c76c8.jar C:\Users\eakhmas\src\ehs-mobile-app\android\app\build\intermediates\pre-dexed\debug\classes_4cc21dc8f1d41e512a3b15b31c7384278c35ea16.jar C:\Users\eakhmas\src\ehs-mobile-app\android\app\build\intermediates\pre-dexed\debug\classes_8443a1d229f534e9bdb905d9a7c4650dfcd0e2cb.jar C:\Users\eakhmas\src\ehs-mobile-app\android\app\build\intermediates\pre-dexed\debug\common-1.0.0_52e55260f7ff638cf5b4c52a3d4ecd72ff2b68c5.jar C:\Users\eakhmas\src\ehs-mobile-app\android\app\build\intermediates\pre-dexed\debug\classes_a094409875a8e375b4bdabde5b620352f56be934.jar C:\Users\eakhmas\src\ehs-mobile-app\android\app\build\intermediates\pre-dexed\debug\support-annotations-26.1.0_49ec6fb643d88a30429e0bf8cc1110f4187f2f7c.jar C:\Users\eakhmas\src\ehs-mobile-app\android\app\build\intermediates\pre-dexed\debug\classes_ae8cb9e283b6addced9a76225a4481dfeaee5c44.jar C:\Users\eakhmas\src\ehs-mobile-app\android\app\build\intermediates\pre-dexed\debug\okhttp-urlconnection-3.6.0_c9d5d04c72d6ed3cbcbec488ff7ee5a2733c6e64.jar C:\Users\eakhmas\src\ehs-mobile-app\android\app\build\intermediates\pre-dexed\debug\classes_6dfedd19702fecc126e9b53000c18d857a6e0d5c.jar C:\Users\eakhmas\src\ehs-mobile-app\android\app\build\intermediates\pre-dexed\debug\classes_8ee3a350c343b0219510f84fdd0023533be789eb.jar C:\Users\eakhmas\src\ehs-mobile-app\android\app\build\intermediates\pre-dexed\debug\classes_02e3d720fdb82b20e5aa7428e558dd7bf8b6f44f.jar C:\Users\eakhmas\src\ehs-mobile-app\android\app\build\intermediates\pre-dexed\debug\jsr305-3.0.0_a4be36913eb9d325c86bf6a1b3098e15106ab59d.jar C:\Users\eakhmas\src\ehs-mobile-app\android\app\build\intermediates\pre-dexed\debug\common-1.0.0_28a97a7622ff8f9b0cca855243ae6d38088c377e.jar C:\Users\eakhmas\src\ehs-mobile-app\android\app\build\intermediates\pre-dexed\debug\classes_6cbdd997c40c58178631de6f736c148cd944033f.jar C:\Users\eakhmas\src\ehs-mobile-app\android\app\build\intermediates\pre-dexed\debug\classes_955a1486e9d329cd6ff1f7ba64e5712405b680f0.jar C:\Users\eakhmas\src\ehs-mobile-app\android\app\build\intermediates\pre-dexed\debug\okio-1.13.0_43a3727954feabd0cb289cfb1a6275d02f742616.jar C:\Users\eakhmas\src\ehs-mobile-app\android\app\build\intermediates\pre-dexed\debug\classes_e604738ac5ee164fbf1cc8194ac891817d7629db.jar C:\Users\eakhmas\src\ehs-mobile-app\android\app\build\intermediates\pre-dexed\debug\classes_1b146f1c1b758f1d3048df22b41ea4f01d14bb9f.jar C:\Users\eakhmas\src\ehs-mobile-app\android\app\build\intermediates\pre-dexed\debug\staticlayout-proxy-1.0_629010e9b49b87eb3b868c71f6b1ed2f650b3f06.jar C:\Users\eakhmas\src\ehs-mobile-app\android\app\build\intermediates\pre-dexed\debug\classes_0c56c37ce4586048238bf0d6a713a9d535becd91.jar C:\Users\eakhmas\src\ehs-mobile-app\android\app\build\intermediates\pre-dexed\debug\classes_16a349b068d84d062e622cef5131e670e6bbfc69.jar C:\Users\eakhmas\src\ehs-mobile-app\android\app\build\intermediates\pre-dexed\debug\classes_225bf35343947bbb02243f47c275f0e818e47b4d.jar C:\Users\eakhmas\src\ehs-mobile-app\android\app\build\intermediates\pre-dexed\debug\classes_911a99756a2506bce883e6a852c2699bf3d26d47.jar C:\Users\eakhmas\src\ehs-mobile-app\android\app\build\intermediates\pre-dexed\debug\classes_4a5530546ee89d9e9b9ca6156857f9df7786484b.jar C:\Users\eakhmas\src\ehs-mobile-app\android\app\build\intermediates\pre-dexed\debug\classes_ac6a27b5609bdd6d8e10bb5cd9ef5472d87d4c88.jar C:\Users\eakhmas\src\ehs-mobile-app\android\app\build\intermediates\pre-dexed\debug\okhttp-3.6.0_bc10fb7a41ba174bd6510ed2632992e096a41cdc.jar}

policz avatar Mar 26 '18 18:03 policz