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

[🐛] A problem occurred gradlew clean RN project. Problem occurred evaluating project ':@react-native-firebase_analytics'. > It is too late to set namespace

Open ssze-vnsny opened this issue 8 months ago • 17 comments

Issue

Found something similar in https://github.com/invertase/react-native-firebase/issues/7801 We are running it on Gitlab CI React Native project for both Android and iOS. It has a parent gitlab-ci and the respective child ones.
Env:

image: reactnativecommunity/react-native-android:latest Kotlin: 1.8.0 Gradle: gradle-8.2-all.zip Java: 17

Follow the same setup as Robert Savage from the prior closed issue android/buil.gradle setting the plugin dependency to not be dynamic so classpath "com.facebook.react:react-native-gradle-plugin:8.2"

Then lastly in my android/app/build.gradle I set this as my dependencies:

dependencies { implementation 'com.facebook.react:react-native:+'

// Exclude Flipper integration if not used
implementation('com.facebook.react:react-native:+') {
    exclude group: 'com.facebook.flipper'
}

implementation 'com.facebook.soloader:soloader:0.10.1+'

}

in the gitlab-ci added this line below to chg the namespace.

  • sed -i "s/namespace project.ext.namespace/namespace 'com.*********app'/" node_modules/@react-native-firebase/analytics/android/build.gradle
    • cd android && ./gradlew clean && cd ..

Describe your issue here Still a showstopper at this specific location Build was configured to prefer settings repositories over project repositories but repository 'maven5' was added by plugin 'com.facebook.react'

Configure project :@react-native-firebase_analytics :@react-native-firebase_analytics package.json found at /builds/.... /node_modules/@react-native-firebase/analytics/package.json

FAILURE: Build failed with an exception.

  • Where: Build file '/builds/... /node_modules/@react-native-firebase/analytics/android/build.gradle' line: 122
  • What went wrong: A problem occurred evaluating project ':@react-native-firebase_analytics'.

It is too late to set namespace It has already been read to configure this project. Consider either moving this call to be during evaluation, or using the variant API.


Project Files

Explained above

Javascript

Click To Expand

package.json:

# N/A

firebase.json for react-native-firebase v6:

# N/A

iOS

Click To Expand

ios/Podfile:

  • [ ] I'm not using Pods
  • [x] I'm using Pods and my Podfile looks like:
# N/A

AppDelegate.m:

// N/A

Android

Click To Expand

Have you converted to AndroidX?

  • [ ] my application is an AndroidX application?
  • [ ] I am using android/gradle.settings jetifier=true for Android compatibility?
  • [ ] I am using the NPM package jetifier for react-native compatibility?

not sure about above but have it below gradle.properties android.enableJetifier=true

android/build.gradle:

// N/A

android/app/build.gradle:

// N/A

android/settings.gradle:

// N/A

MainApplication.java:

// N/A

AndroidManifest.xml:

<!-- N/A -->

Environment

Click To Expand

react-native info output:

 OUTPUT GOES HERE
  • Platform that you're experiencing the issue on:
    • [ ] iOS
    • [x] Android
    • [x] iOS but have not tested behavior on Android
    • [ ] Android but have not tested behavior on iOS
    • [ ] Both
  • react-native-firebase version you're using that has this issue:
    • e.g. 5.4.3
  • Firebase module(s) you're using that has the issue:
    • e.g. Instance ID
  • Are you using TypeScript?
    • Y/N & VERSION

package.json "@react-native-firebase/analytics": "^21.13.0", "@react-native-firebase/app": "^21.13.0",


ssze-vnsny avatar Apr 07 '25 16:04 ssze-vnsny

Instead of using 'sed' to set the namespace, try set it in your gradle files instead.

MichaelVerdon avatar Apr 08 '25 09:04 MichaelVerdon

Thanks Michael for your response, but I did try. Not sure if all these gradle files has any overlap and causing issues?

ssze-vnsny avatar Apr 08 '25 10:04 ssze-vnsny

You've logged a build issue that seems to focus on incompatible versions

You have provided no version information

Those two things don't seem to go together...

mikehardy avatar Apr 08 '25 13:04 mikehardy

Thank you Mike for your response. This is a 5 year old mobile app that needs to be migrated from AppCenter (decommed) to GitLab. Is there a version standard btw package.json with all its dependencies ver and script calls, android/build.gradle, android/app/build.gradle seems to inherits the parent ver, gradle.properties seems to be the overlap btw build.gradle and gradle.properties, and the gradle-wrapper.properties seems to be the dist ver ONLY. Plus due to some Gitlab issues with disk space, cache, and token to import libraries from github, I decided to go with the Docker image thats prepackaged. I did run an echo to check all the ver. All 3 AI helps, but it somewhat seems to mislead you into an infinite loop... Im not a DevOps guy, more of a full stack Java guy that is working on this since there is no DevOps in this company.

ssze-vnsny avatar Apr 08 '25 13:04 ssze-vnsny

Also does following npx react-native info and gradlew dependencies helps, or it will take me down to a deeper rabbit hole?

ssze-vnsny avatar Apr 08 '25 13:04 ssze-vnsny

https://github.com/mikehardy/rnfbdemo/blob/main/make-demo.sh

There are an infinite number of ways to do things wrong so they don't build, and it's an impossible task to fix them all.

So that script above is a demonstrator of how exactly to do it correctly. You can read it, read the comments, run it, and it'll generate a project that builds without taking infinite maintainer time troubleshooting project-specific errors

mikehardy avatar Apr 08 '25 14:04 mikehardy

Thank you Mike, will definitely do, cheers!

ssze-vnsny avatar Apr 08 '25 14:04 ssze-vnsny

Nice script Mike. I havent executed yet, I just went thru it, this must have taken you awhile to figure out all the versions working together? How about all the versions and dependencies inside package.json?

ssze-vnsny avatar Apr 10 '25 14:04 ssze-vnsny

My contract here is to make all the versions work, so it's not like I figured out things that were compatible, it's that around 4 years ago I took "current and last couple versions of everything" and I fixed all the issues here and upstream in react-native as needed. And I've continued to do that over the years such that whatever "current" is at the time, as a set of versions, works.

When react-native is in the rc phase for a new release, I start pre-testing it and sometimes there are problems - I collaborate with upstream to iron them out before the full release of react-native is made, or I fix things locally here, such that when react-native does a release, react-native-firebase also has a release ready that works.

So the basic idea is: stay current. Current stable of all the packages works together at any point in time, because that's what I'm specifically working on and testing. The chain of commits in the make-demo.sh file is just a snapshot of that work, with whatever current is at the time, all working together.

mikehardy avatar Apr 10 '25 16:04 mikehardy

Thanks Mike for the quick response, do I need to update the package.json? Since I do not see in the script that modifies that file. Sorry for the silly question.. Thanks again in advance!

ssze-vnsny avatar Apr 10 '25 16:04 ssze-vnsny

Your script Mike uses Expo, we do not use Expo. We're not sure how secure is it. We're setting up Gitlab Devops for our build and dist. MS AppCenter seems to be easier. Still trying to get rid of the inconsistencies

ssze-vnsny avatar Apr 10 '25 22:04 ssze-vnsny

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 attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.

github-actions[bot] avatar May 10 '25 18:05 github-actions[bot]

Your script Mike uses Expo

No it does not. My script specifically uses react-native-community CLI and bare react-native. This would be evident upon reading the script, unless we are somehow looking at different scripts ?

mikehardy avatar May 12 '25 19:05 mikehardy

Hi Mike

do I need to update package.json? settings.gradle? build.gradle? etc or just run your script?.

Thanks again Steve

ssze-vnsny avatar May 16 '25 15:05 ssze-vnsny

@ssze-vnsny I don't know what you'll need to do. My script is a build demonstrator, nothing more nothing less. It simply demonstrates how to create a working / correctly compiling build from scratch. In this way it shows how to do something.

Whether you do that correctly in your own project or not, is not something I'm in control of - I just try to show how

mikehardy avatar May 16 '25 23:05 mikehardy

Thanks @mikehardy , it is a preexisting project. So I decided to go to RN v0.65.3, still working on the libraries needed

ssze-vnsny avatar May 21 '25 23:05 ssze-vnsny

@mikehardy I used your script to build a demo project and compare to the initial RN project npx by running the following @react-native-community/cli init MyApp --version 0.70.6

Both seems to work nicely but once I start to install libraries like npm install @react-native-async-storage/async-storage npm install @react-navigation/stack

everything starts to be incompatible. asking me to downgrade or upgrade. So painful.... LOL

stevesze avatar Jun 05 '25 13:06 stevesze

@mikehardy just want to say thank you. I was able to get the build, lint, test and install without issues but the virtual devices is giving an issue. right now it is at RN 0.80.0, I will try to downgrade back to 0.73.6 - Latest stable (recommended)

stevesze avatar Jun 23 '25 19:06 stevesze

Hi there @ssze-vnsny are you still experiencing this issue or have you been able to solve it?

MichaelVerdon avatar Jul 08 '25 13:07 MichaelVerdon

hey there @MichaelVerdon , thanks for asking. Getting better! Seems like I may have to rebuild this app? I was hoping to make minimize chgs and then just get it to work.

Just a question for you and everyone. Does everyone use Expo? If so, is it safe and secure? We remember our consultant mentioned that it was not safe but that was like 5 years ago. or is it the same effort?

ssze-vnsny avatar Jul 08 '25 13:07 ssze-vnsny

@MichaelVerdon looks like a lot of problems btw navigation and gesture dependencies with RN 79.2. let me know if I should down grade RN?

ssze-vnsny avatar Jul 10 '25 18:07 ssze-vnsny

hey there @MichaelVerdon , thanks for asking. Getting better! Seems like I may have to rebuild this app? I was hoping to make minimize chgs and then just get it to work.

Just a question for you and everyone. Does everyone use Expo? If so, is it safe and secure? We remember our consultant mentioned that it was not safe but that was like 5 years ago. or is it the same effort?

Hey there, whilst you can use Expo I wouldn't personally recommend it just because it can get tricky with getting things to work. In terms of security, it seems Expo was made with security in mind https://docs.expo.dev/app-signing/security/ I think up to you to measure the pros and cons of each.

MichaelVerdon avatar Jul 14 '25 12:07 MichaelVerdon

Thanks @MichaelVerdon , I'll stick to the standard since Im migrating a 4 year old project over. I think it's getting better. Hope I do not hit another snag with RN 79.2. Rebuilding page by page.

ssze-vnsny avatar Jul 14 '25 13:07 ssze-vnsny

@MichaelVerdon looks like a lot of problems btw navigation and gesture dependencies with RN 79.2. let me know if I should down grade RN?

I am personally using 0.77 and it seems to be ok, you can try a downgrade to that version and see how it goes.

MichaelVerdon avatar Jul 14 '25 13:07 MichaelVerdon

@MichaelVerdon @mikehardy so it works on a Win laptop but keeps failing on the Macbook with autolinking. Do you guys have that issue?

ssze-vnsny avatar Jul 30 '25 19:07 ssze-vnsny

@MichaelVerdon RN 0.77 does not exist. Do you mean 0.76?

ssze-vnsny avatar Jul 30 '25 20:07 ssze-vnsny

@MichaelVerdon RN 0.77 does not exist. Do you mean 0.76?

https://reactnative.dev/versions latest version of React Native is 0.81. I believe we use 0.78.2 on our test apps.

MichaelVerdon avatar Aug 27 '25 05:08 MichaelVerdon

I'm going to close this as not actionable in this repo. We definitely do not have android build problems in general though in the infinite variety of versions people can try between react-native, gradle, kotlin, and java, and the android-gradle-plugin it is obviously possible to run into trouble.

At all times you can see the versions we use in our test project that builds constantly for CI e2e test runs, or you can examine https://github.com/mikehardy/rnfbdemo/blob/main/make-demo.sh which I use to test out current version compatibility whenever some part of the toolchain is upgraded

Those will at least give reference values for "things that work" and is the only supportable way I've found to describe versions, vs "examine every possible combination" which is not sustainable as an effort

mikehardy avatar Aug 29 '25 15:08 mikehardy

Thanks @mikehardy yep, the android is fixed. The issue was the following;

app/build.gradle, needed to grey out buildTypes { debug { signingConfig signingConfigs.debug <--------- }

stevesze avatar Aug 30 '25 14:08 stevesze