React-native-firebase: MultiDex needing in Android and having to remove build folder on every launch

Created on 23 Mar 2020  路  14Comments  路  Source: invertase/react-native-firebase

Hello everybody, I was developing a project with the version 6.3.4.

Everytime when I run my Android project I have to remove my android/build to it finish the build, because if I don't I got a problem with google-services.json.

If anyone needs more details, I can pass it, no problem.

*Sorry, if it lack of details, I'm not an Issue Reporter, this is my first. (:

No Template Stale >= 6

All 14 comments

Have you encountered this problem?

> Task :app:transformClassesWithMultidexlistForDebug FAILED 
D8: Program type already present: io.invertase.firebase.BuildConfig

FAILURE: Build failed with an exception.

* What went wrong:
> Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
> com.android.build.api.transform.TransformException: Error while generating the main dex list:
  Error while merging dex archives:
  Program type already present: io.invertase.firebase.BuildConfig
  Learn how to resolve the issue at > 
https://developer.android.com/studio/build/dependencies#duplicate_cl

I'm not able to run my application, even though I make all the changes to the native code to work with DEX

I created a gist with my build.gradle, mainApplication and Error 馃憞
https://gist.github.com/eugustavo/ec3a29277433ea30e0487a7941f8a100

@eugustavo I have a hunch this is a problem with Android Studio 4.0

People aren't following the template so I can't say definitively, but if you can still reproduce this with Android Studio 3.4 (current stable, not a beta version) and gradle plugin 3.6.1 (current stable) I will be surprised

cross link: #3254

If you run my example here, which should build current stable versions of everything, I believe it still works? https://github.com/mikehardy/rnfbdemo/blob/master/make-demo-v6.sh

@eugustavo I had this problem before, I just removed the build folder at android/app and it worked for me.

The main problem here, is that everytime I launch, I need to remove this same build folder because if I don't, it simply doesn't start.

If you have linked the package manually, then you have to disable auto-linking of specific package by creating a file react-native.config.js in base project folder like this:
module.exports = { dependencies: { '@react-native-firebase/app': { platforms: { android: null }, }, '@react-native-firebase/crashlytics': { platforms: { android: null }, }, }, }

@eugustavo I had this problem before, I just removed the build folder at android/app and it worked for me.

The main problem here, is that everytime I launch, I need to remove this same build folder because if I don't, it simply doesn't start.

I found the problem in the application. It consisted that the same lib was being used 2 times in different versions.
I solved that and the application made the build, but now it always closes when it loads, I'm checking this error now. Hope this helps!
depen

@eugustavo I don't have this in my package.json, but I'm really glad you found the problem in your project. Well, I'm digging a little to found the problem in my project to erase the build folder anytime I run react-native start

@BrianIto
Im also facing same issue
and since the very start im not using react-native-firebase
All im using is
Screenshot 2020-04-08 at 6 36 57 PM

Its very strange
It only comes since i did this change
multiDexEnabled true in defaultConfig section of build.gradle

But i need to do this to avoid some other dex error...

I've added this to the docs: https://rnfirebase.io/#android-enabling-multidex

@BrianIto Did you come across any workaround for this issue ?
For me even deleting build thing doesnt work.

It keeps on throwing the below error:

`

Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
com.android.build.api.transform.TransformException: Error while generating the main dex list:
Error while merging dex archives:
Program type already present: io.invertase.firebase.BuildConfig
Learn how to resolve the issue at >
https://developer.android.com/studio/build/dependencies#duplicate_cl`

Also since the very start i have been using
Screenshot 2020-04-08 at 6 36 57 PM

And no other firebase package ever.
That's why i'm more shocked looking at other's solution.
they ask to remove react-native-firebase but i dont have any...

Hello 馃憢, to help manage issues we automatically close stale issues.
This issue has been automatically marked as stale because it has not had activity for quite some time. Has this issue been fixed, or does it still require the community's attention?

This issue will be closed in 15 days if no further activity occurs.
Thank you for your contributions.

Closing this issue after a prolonged period of inactivity. If this is still present in the latest release, please feel free to create a new issue with up-to-date information.

hey @gotyet9 did you figure out the solution to this? Cheers

Well, finally I solved this problem by disable auto-linking.
First create a file name react-native.config.js in your root of project with the following content:

module.exports = {
  dependencies: {
    '@react-native-firebase/app': { platforms: { android: null } },
    '@react-native-firebase/messaging': { platforms: { android: null } },
//all the packages related to firebase
  },
};

After that, please link you package manually and update your project (pod, android libraries).
npx react-native run-android

I have tried all the solutions and only this worked for me. Hope this help!

I'm glad you found a solution, but disabling auto-linking is a drastic step, I would only do it as a last resort. There are thousands (a hundred thousand maybe?) users of react-native-firebase and this does not show up often, so I suspect the underlying cause is a local project misconfiguration somehow, that still bears investigation / comparison (perhaps with https://github.com/mikehardy/rnfbdemo/blob/master/make-demo-v6.sh ?) so we can reproduce the problem and fix it if so.

Was this page helpful?
0 / 5 - 0 ratings