React-native-firebase: [v6] πŸ”₯Unable to install as per quick start guide

Created on 9 May 2019  Β·  66Comments  Β·  Source: invertase/react-native-firebase


Issue



Describe your issue here

As per docs tried running:
npx @react-native-community/cli@next init --template=@react-native-firebase/template@alpha <myProjectName>

Install does not complete, error:
error Error: Cannot find module '/var/folders/s7/v2pwtdc96fzbv2s8j10mf3340000gn/T/rncli-init-template-k19y8J/node_modules/@react-native-firebase/template@alpha/template.config'



Think react-native-firebase is great? Please consider supporting all of the project maintainers and contributors by donating via our Open Collective where all contributors can submit expenses. [Learn More]

React Native Bug Stale >= 6

Most helpful comment

Published @react-native-community/[email protected] with the fix

All 66 comments

cc @thymikee - think this is a bug on the CLI with templates, the path to the template.config file being loaded has the NPM tag @alpha tag in the path (and also the @ from the NPM org) - should be stripped out I'm guessing. Must be a recent bug - was working a couple of days ago.

- error Error: Cannot find module '<truncated>/@react-native-firebase/template@alpha/template.config'
+ error Error: Cannot find module '<truncated>/react-native-firebase/template/template.config'

Thanks for the report @matthieunelmes πŸ‘

I have the same issue

@Salakar we didn't have a release in ~20 days. This is a bug indeed, fixed in https://github.com/react-native-community/cli/pull/364. We'll have a release shortly, right after https://github.com/react-native-community/cli/pull/372 is merged (I'm waiting for someone to review it once again, help appreciated πŸ˜ƒ)

Published @react-native-community/[email protected] with the fix

Thanks for jumping on this, look forward to trying it out

Sorry guys, no dice.

Can successfully install via the template, trying to follow docs and have installed .plist into the Xcode project but it's failing to build. Have tried auto-linking, manual linking, installing via pods, building via workspace but nothing is working. Keep getting:

'Firebase/Firebase.h' file not found

Not really the quick start I had in mind πŸ˜•and the docs feel very sporadic. I would love to contribute to the docs if only I knew the correct process to get a working build.

@matthieunelmes please post your own issue, we have no idea what your setup is, and your error seems to be unrelated

@mikehardy This is my own issue and this by following the Quick start guide:

Integrating with existing project:
https://invertase.io/oss/react-native-firebase/quick-start/existing-project

Adding Firebase to iOS: (Title on page is incorrect as it says Android)
https://invertase.io/oss/react-native-firebase/quick-start/ios-firebase-credentials

On that first link there are even TODO's left in the text!
// TODO(salakar) React Native version requirements
// TODO(salakar): Manual or Automatic linking for Android & ios

I'm sorry that you seem to have taken an exception to the way I've worded my issues, but clearly the docs are incomplete. I've followed both guides in the links above (non-pods setup) and the Xcode error I'm getting is 'Firebase/Firebase.h' file not found

Apologies! I did not see this was your own issue. We get a lot of people posting months-old followups on issues and I was scanning very quickly, let me look more closely

That's ok, as I say. I'm happy to help contribute to documentation once we find out what is going wrong

I see this is for the new-new stuff (CLI next etc) - I can say I tried to use all the v6 stuff and new-CLI and all that yesterday in order to make a repro case for the firebase ios sdk (which has moved to a version that react-native-firebase 5.3.x doesn't support as it is locked to 5.20.2 firebase-ios if I understand correctly), and I met with failure as well. I think it's just not baked enough yet personally (though it is labeled correctly with alphas and nexts and WIPs etc)

I got farther than the error message you indicated, but gradle wouldn't build android, with some sort of iterator error I did not dig into

I will re-try in a couple revisions but I didn't personally have time to fuzzbust, I use react-native-firebase 5.3.x exclusively for actual work

Sorry I can't help more

I would suggest indicating clearly in the title of this issue that it is a react-native-firebase 6.x issue, as 5.3.x and 6.x are very different beasts. I check the 5.3.x start periodically (as recently as a week ago even) and I know it works at least

Could you kindly link me to any V5 documentation?

EDIT
I've found it:
https://rnfirebase.io/docs/v5.x.x/getting-started

Yep :-)

And there are links to the corresponding github there

I find the starter to be the best way to start. This is just a mountain of code with you think about how much functionality is coming with the firebase SDKs, the react-native-firebase module is really not so thick a wrapper, it's just an enormous amount of functionality. So the adaptation into a project is not trivial at all. The starter does two things at once - proves it work (thus proving your local environment and letting you know it's possible, for motivation), and giving you a basis for a correct integration

https://github.com/invertase/react-native-firebase-starter/

@mikehardy thanks, Appreciate your help

@mikehardy I got farther than the error message you indicated, but gradle wouldn't build android, with some sort of iterator error I did not dig into

Do you remember what this error was?

@matthieunelmes I'm getting is 'Firebase/Firebase.h' file not found

There's still some work to be done if not using Pods, it has been a bit low prior for early v6 as Pods will be the default in RN 0.60 onwards. Basically, the header search paths just need a bit of a re-work in v6, see: https://github.com/invertase/react-native-firebase/pull/2080 (incomplete though as doesn't do all modules, needs completing)

@Salakar thanks, I'll take another look. In the meantime, I managed to get a v5 instance up and running.

@Salakar Yeah, the android run-after-init error is immediate. Unsure how run-android is working for anyone right now after project init?

mike@isabela:~/work/react-random/TEMP % npx @react-native-community/cli@next init --template=@react-native-firebase/template@alpha RNFBv6StarterTest
npx: installed 633 in 5.428s

               ######                ######               
             ###     ####        ####     ###             
            ##          ###    ###          ##            
            ##             ####             ##            
            ##             ####             ##            
            ##           ##    ##           ##            
            ##         ###      ###         ##            
             ##  ########################  ##             
          ######    ###            ###    ######          
      ###     ##    ##              ##    ##     ###      
   ###         ## ###      ####      ### ##         ###   
  ##           ####      ########      ####           ##  
 ##             ###     ##########     ###             ## 
  ##           ####      ########      ####           ##  
   ###         ## ###      ####      ### ##         ###   
      ###     ##    ##              ##    ##     ###      
          ######    ###            ###    ######          
             ##  ########################  ##             
            ##         ###      ###         ##            
            ##           ##    ##           ##            
            ##             ####             ##            
            ##             ####             ##            
            ##          ###    ###          ##            
             ###     ####        ####     ###             
               ######                ######               


                  Welcome to React Native!                
                 Learn Once Write Anywhere                

βœ” Downloading template
βœ” Copying template
βœ” Processing template
βœ” Installing all required dependencies

  Run instructions for iOS:
    β€’ cd /home/mike/work/react-random/TEMP/RNFBv6StarterTest && react-native run-ios
    - or -
    β€’ Open ios/RNFBv6StarterTest.xcodeproj in Xcode
    β€’ Hit the Run button

  Run instructions for Android:
    β€’ Have an Android emulator running (quickest way to get started), or a device connected.
    β€’ cd /home/mike/work/react-random/TEMP/RNFBv6StarterTest && react-native run-android

command not found: react-native
mike@isabela:~/work/react-random/TEMP % cd RNFBv6StarterTest/
mike@isabela:~/work/react-random/TEMP/RNFBv6StarterTest % npx react-native run-android
error Cannot read property 'indexOf' of undefined. Run CLI with --verbose flag for more details.
mike@isabela:~/work/react-random/TEMP/RNFBv6StarterTest % 

Imagine this may be another CLI issue @mikehardy .

I know command not found: react-native is caused by a commit on RN that removed the bin from the package.json, this was reverted in the next version iirc, so this one at least is just the template needs a newer RN version. πŸ™ˆ

As for error Cannot read property 'indexOf' of undefined. Run CLI with --verbose flag for more details. I think this is related to the CLI, maybe cc @thymikee again if you know of anything immediate about this? If not np, I can debug next week.

I figure this is all CLI yes, just a bit stretched myself and figured I wasn't a snowflake in my attempt so didn't chase just now - was going to take a "wait and try in a week" approach. 5 days left on that timer :)

Will try to have a look at this today

FYI @Salakar, this is here from the very beginning, but just to let you know, while doing

init --template @react-native-firebase/template@alpha RNFBv6StarterTest

I get an error when installing pods:

[!] No podspec found for `React-Core` in `../node_modules/react-native/React`

This is likely because Podfile used here is taken from RN master (or 0.60-stable branch), while we're installing RN 0.59.

I just released a new version of CLI (alpha.20) and as far as Android goes, I can't repro the error you point to. I just end up with "File google-services.json is missing." which I guess is expected because I didn't add any.

Also feel free to use 2.0.0-alpha.20 in the template and get rid of patch-package because it's not necessary for a long time now.

Ah - okay, thanks @thymikee - I'll zero the timer now and put this on the "re-test" pile for the day. If I can reproduce what I saw I'll post exact steps

@thymikee

I think this is related to me not having react-native installed globally. I use npx to reference it in node_modules/.bin

You can see the CLI prints an error message that assumes I have a global install of something (but doesn't check to see if that dep is satisfied), and then when I manually alter it to add npx as a command pre-fix, I get the error.

Should be easy to reproduce? Either my workflow is off the supported-usage rails (at which point a dep check / doc ref like the "doctor" ideas would be useful), or something is wrong?


error Cannot read property 'indexOf' of undefined

mike@isabela:~/work/react-random/TEMP % npx @react-native-community/cli@next init --template=@react-native-firebase/template@alpha RNFB6Test
npx: installed 632 in 31.874s

               ######                ######               
             ###     ####        ####     ###             
            ##          ###    ###          ##            
            ##             ####             ##            
            ##             ####             ##            
            ##           ##    ##           ##            
            ##         ###      ###         ##            
             ##  ########################  ##             
          ######    ###            ###    ######          
      ###     ##    ##              ##    ##     ###      
   ###         ## ###      ####      ### ##         ###   
  ##           ####      ########      ####           ##  
 ##             ###     ##########     ###             ## 
  ##           ####      ########      ####           ##  
   ###         ## ###      ####      ### ##         ###   
      ###     ##    ##              ##    ##     ###      
          ######    ###            ###    ######          
             ##  ########################  ##             
            ##         ###      ###         ##            
            ##           ##    ##           ##            
            ##             ####             ##            
            ##             ####             ##            
            ##          ###    ###          ##            
             ###     ####        ####     ###             
               ######                ######               


                  Welcome to React Native!                
                 Learn Once Write Anywhere                

βœ” Downloading template
βœ” Copying template
βœ” Processing template
βœ” Installing all required dependencies

  Run instructions for iOS:
    β€’ cd /home/mike/work/react-random/TEMP/RNFB6Test && react-native run-ios
    - or -
    β€’ Open ios/RNFB6Test.xcodeproj in Xcode
    β€’ Hit the Run button

  Run instructions for Android:
    β€’ Have an Android emulator running (quickest way to get started), or a device connected.
    β€’ cd /home/mike/work/react-random/TEMP/RNFB6Test && react-native run-android

mike@isabela:~/work/react-random/TEMP % cd /home/mike/work/react-random/TEMP/RNFB6Test && react-native run-android
react-native: command not found
mike@isabela:~/work/react-random/TEMP/RNFB6Test % cd /home/mike/work/react-random/TEMP/RNFB6Test && npx react-native run-android
error Cannot read property 'indexOf' of undefined. Run CLI with --verbose flag for more details.
mike@isabela:~/work/react-random/TEMP/RNFB6Test % 


I don't have react-native installed globally either, I used a local installation. Will try with npx later

Ok, got some updates for you @mikehardy:

  1. I think you're running some kind of cached version of the CLI through npx, is that possible? Your installation should fail during installation phase because Podfile is wrong in the installed template.
  2. You're running npx react-native which runs React Native 0.59! The features we're talking about are available on yet unreleased RN 0.60. You need to run:
npx @react-native-community/cli@next run-android

Just to be clear, since 0.60 you will be able to simply run npx react-native but just not yet. It's still not released even in RC channel.

Esp about the npx using 0.59 that makes sense @thymikee - testing the unreleased stuff is a bit hard, making it all use the unreleased versions. Unsure about cached versions but I hadn't thought about version mismatches so I'll beat against this with that in mind now. Thanks!

just in case you can use 2.0.0-alpha.20 instead of next

@thymikee :thinking: I believe I figured it out - TL;DR: obsolete CLI dep in the react-native-firebase@6 template

But there is maybe something to learn

Current failure - something about running the auto-config script did not work and the error message wasn't very good - it didn't error in the way that the script thought it would. It errored with no output in place of an actual error


install attempt

mike@isabela:~/work/react-random % npm list --depth=0 -g
/home/mike/.nvm/versions/node/v12.2.0/lib
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
└── [email protected]

mike@isabela:~/work/react-random % npx @react-native-community/cli@next init  --template=@react-native-firebase/template@alpha RNFB6Test
npx: installed 632 in 31.664s

               ######                ######               
             ###     ####        ####     ###             
            ##          ###    ###          ##            
            ##             ####             ##            
            ##             ####             ##            
            ##           ##    ##           ##            
            ##         ###      ###         ##            
             ##  ########################  ##             
          ######    ###            ###    ######          
      ###     ##    ##              ##    ##     ###      
   ###         ## ###      ####      ### ##         ###   
  ##           ####      ########      ####           ##  
 ##             ###     ##########     ###             ## 
  ##           ####      ########      ####           ##  
   ###         ## ###      ####      ### ##         ###   
      ###     ##    ##              ##    ##     ###      
          ######    ###            ###    ######          
             ##  ########################  ##             
            ##         ###      ###         ##            
            ##           ##    ##           ##            
            ##             ####             ##            
            ##             ####             ##            
            ##          ###    ###          ##            
             ###     ####        ####     ###             
               ######                ######               


                  Welcome to React Native!                
                 Learn Once Write Anywhere                

βœ” Downloading template
βœ” Copying template
βœ” Processing template
βœ” Installing all required dependencies

  Run instructions for iOS:
    β€’ cd /home/mike/work/react-random/RNFB6Test && react-native run-ios
    - or -
    β€’ Open ios/RNFB6Test.xcodeproj in Xcode
    β€’ Hit the Run button

  Run instructions for Android:
    β€’ Have an Android emulator running (quickest way to get started), or a device connected.
    β€’ cd /home/mike/work/react-random/RNFB6Test && react-native run-android

mike@isabela:~/work/react-random % cd RNFB6Test
mike@isabela:~/work/react-random/RNFB6Test % npx @react-native-community/cli@next run-android
npx: installed 632 in 5.456s
info JS server already running.
info Installing the app...

FAILURE: Build failed with an exception.

* Where:
Script '/home/mike/work/react-random/RNFB6Test/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' line: 187

* What went wrong:
A problem occurred evaluating settings 'RNFB6Test'.
> Text must not be null or empty

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 0s

error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.

So I checked that line out:

mike@isabela:~/work/react-random/RNFB6Test % cat -n node_modules/@react-native-community/cli-platform-android/native_modules.gradle | head -200 |tail -40
   161      treeBuilder.file(generatedFileName).newWriter().withWriter { w ->
   162        w << generatedFileContents
   163      }
   164    }
   165  
   166    /**
   167     * Runs a process to call the React Native CLI Config command and parses the output
   168     *
   169     * @return ArrayList < HashMap < String , String > >
   170     */
   171    ArrayList<HashMap<String, String>> getReactNativeConfig() {
   172      if (this.reactNativeModules != null) return this.reactNativeModules
   173      ArrayList<HashMap<String, String>> reactNativeModules = new ArrayList<HashMap<String, String>>()
   174  
   175      def cmdProcess
   176  
   177      try {
   178        cmdProcess = Runtime.getRuntime().exec(REACT_NATIVE_CONFIG_CMD, null, getReactNativeProjectRoot())
   179        cmdProcess.waitFor()
   180      } catch (Exception exception) {
   181        this.logger.warn("${LOG_PREFIX}${exception.message}")
   182        this.logger.warn("${LOG_PREFIX}Automatic import of native modules failed. (UNKNOWN)")
   183        return reactNativeModules
   184      }
   185  
   186      def reactNativeConfigOutput = cmdProcess.in.text
   187      def json = new JsonSlurper().parseText(reactNativeConfigOutput)
   188      def dependencies = json["dependencies"]
   189  
   190      dependencies.each { name, value ->
   191        def platformsConfig = value["platforms"];
   192        def androidConfig = platformsConfig["android"]
   193  
   194        if (androidConfig != null && androidConfig["sourceDir"] != null) {
   195          this.logger.info("${LOG_PREFIX}Automatically adding native module '${name}'")
   196  
   197          HashMap reactNativeModuleConfig = new HashMap<String, String>()
   198          reactNativeModuleConfig.put("name", name)
   199          reactNativeModuleConfig.put("nameCleansed", name.replaceAll('/', '_'))
   200          reactNativeModuleConfig.put("androidSourceDir", androidConfig["sourceDir"])

And I dumped state on the arguments to the command that was returning empty:

config is node node_modules/@react-native-community/cli/build/index.js config
project root is /home/mike/work/react-random/RNFB6Test

Hmm

mike@isabela:~/work/react-random/RNFB6Test % ls -lat node_modules/@react-native-community/cli/index.js
ls: cannot access 'node_modules/@react-native-community/cli/index.js': No such file or directory

what? So if there is some failure in the script, the error messaging is bad, which leads to this conversation and future conversations like this

Anyway, it made me suspicious, so I checked something

mike@isabela:~/work/react-random/RNFB6Test % cat package.json |grep cli
    "@react-native-community/cli": "2.0.0-alpha.13",

Ah ha!

https://github.com/invertase/react-native-firebase/blob/master/packages/template/project/package.json#L22

I fix that, and it starts to work. Shouldn't that be a '^' dependency? And shouldn't the other ones also be carets, or nexts, so it doesn't go stale (c.f. 0.59.5)

@Salakar - you want a PR for your v6 template?

CLI alpha dependencies should either be pinned or using next npm tag.

for a template, where updating will always be a forgotten chore, I'd go for next. I used that while fuzz-busting and it worked. But now I have a separate non-CLI issue

Looks like some chunk of java moved packages and the template wasn't moved with it:

/home/mike/work/react-random/firebaseanalyzertests/android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java:18: error: cannot find symbol
import io.invertase.firebase.ReactNativeFirebaseAppPackage;
                            ^
  symbol:   class ReactNativeFirebaseAppPackage
  location: package io.invertase.firebase
/home/mike/work/react-random/firebaseanalyzertests/android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java:45: error: cannot find symbol
      new ReactNativeFirebaseAnalyticsPackage(),new ReactNativeFirebaseAppPackage()
                                                    ^
  symbol:   class ReactNativeFirebaseAppPackage
  location: class PackageList
2 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 2s

error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment.
debug Error: Command failed: ./gradlew app:installDebug
/home/mike/work/react-random/firebaseanalyzertests/android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java:18: error: cannot find symbol
mike@isabela:~/work/react-random/firebaseanalyzertests % find . |grep ReactNativeFirebaseAppPackage
./node_modules/@react-native-firebase/app/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/io/invertase/firebase/app/ReactNativeFirebaseAppPackage.class
./node_modules/@react-native-firebase/app/android/src/main/java/io/invertase/firebase/app/ReactNativeFirebaseAppPackage.java

import io.invertase.firebase.ReactNativeFirebaseAppPackage; --> import io.invertase.firebase.**app**.ReactNativeFirebaseAppPackage'

But I'm not sure where that file comes from etc so I'm still plowing through

Getting there though

@Salakar @thymikee hey guys - after investigating this a little more it dawned on me that if I see a path like /home/mike/work/react-random/firebaseanalyzertests/android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java it's ...probably "generated" by the "rncli", and my knowledge there is zero but I think there some sort of baton pass between react-native-firebase v6 and cli@next

You won't be able to reproduce that unless you have a google-services.json file from a firebase project, but they are free to create - you just have to add an android app and then match the package name you chose with the name you use to init the react-native-firebase template with

Near as I can tell the react-native-firebase v6 template is not usable right now though, without at least version changes in the templates package.json, and something altered in the connection between cli and rn-firebase template

@Salakar mind taking a look? Is the config command returning wrong import path?

@Salakar mind taking a look? Is the config command returning wrong import path?

I will update the template today and try everything out, I believe we removed the old rnpm configs already, it's just not been published yet

Ok published an updated template to a CLI tag quickly, untested yet (can't test until this evening) but if anyone wants to try:

npx @react-native-community/cli@next init --template=@react-native-firebase/template@cli <myProjectName>
(note the template@cli tag)

@Salakar I'm getting

βœ” Downloading template
βœ” Copying template
βœ” Processing template
β ™ Installing all required dependencies
[!] Invalid `Podfile` file: [!] No podspec exists at path `/Users/matthieunelmes/Desktop/projects/reactFirebaseTest/node_modules/@react-native-firebase/analytics/.podspec`..

 #  from /Users/matthieunelmes/Desktop/projects/reactFirebaseTest/ios/Podfile:36
 #  -------------------------------------------
 #  
 >    use_native_modules!
 #  end
 #  -------------------------------------------

βœ– Installing all required dependencies
error Error: Failed to install CocoaPods dependencies for iOS project, which is required by this template.
Please try again manually: "cd ./reactFirebaseTest/ios && pod install".
CocoaPods documentation: https://cocoapods.org/

@matthieunelmes hmm ok I know what this is - the podspecs for the packages need moving to the root of their package (auto-linking now expects these to be at the root), right now they're in <package>/ios/*.podspec this should be <package>/*.podspec - I will get this sorted later today and publish a new alpha am not at my computer again until the evening sorry.

No rush on my part, just trying to help you guys push all this stuff forward. Thanks

@Salakar I'm getting

[!] Invalid Podfile file: [!] No podspec exists at path

And just for clarity, I have been testing on linux, which may explain why I was not seeing any issues with regard to pods etc. Does autolinking have to be done mac now, or does it sort of re-link every time, meaning I can do it once on linux and later on mac? (that's my normal use case, my main dev rig is linux and I usually switch to macOS after to mop up inconsistencies in a trailing manner)

Autolinking happens per platform while building native deps. If you're not on a Mac the we don't run pod install which triggers linking on ios. Android is unaffected and should work on Linux, maybe just not yet with this template

@thymikee If you're not on a Mac the we don't run pod install which triggers linking on ios.

Are you running pods related commands manually on linux somehow @mikehardy, if not then I'd say this is the CLI logic @thymikee mentioned above not functioning correctly as Invalid Podfile file: [!] No podspec exists at path is a CocoaPods error - which shouldn't be running on Linux automatically - only on darwin specifically?

We do check for process.platform === 'darwin' before we run "pod install" πŸ€”
https://github.com/react-native-community/cli/blob/c2fb83fb641e5800e9ceb22935256d1240b8eba1/packages/cli/src/commands/init/init.js#L164-L166

@thymikee probably not the CLI then :D

Sorry I seem to have created confusion when I was trying to clarify. You have two testers working with you here. Me, testing on linux, and I got much farther than podspec issues, reporting some Java issue during build (which is where "auto-linking" does some of it's work now), not during install/init. And I was just trying to explain why that was happening when your other tester here @matthieunelmes was seeing different errors related to Pods.

The explanation of auto-linking was great though, I can see why I'm not tripping on that yet, and I understand better how the auto-linking will affect my flow later when it becomes standard (with the TL;DR there being: no flow affect at all, just build on whatever platform you're on and it figures it out)

Ah ok makes sense @mikehardy sorry - I did a confuse πŸ˜…

FYI - I'm working through the template at the moment, moving the specs and testing 🀞

Ok, 1 PR up for the CLI: https://github.com/react-native-community/cli/pull/393 -> not really a blocker right now but is something that will be needed in an upcoming change landing in the mlkit branch - so best to get it out the way.

Another CLI PR to go; I need to finish up the iOS custom script phases config for auto-linking - it's supported in the ruby script but not in js yet.

Hey guys - just FYI, I re-ran my previous commands on linux, but this time during the init I pulled the template@cli tag you mentioned

I received the same error indicating auto-linking is looking for the wrong packages as I received above in https://github.com/invertase/react-native-firebase/issues/2126#issuecomment-493236074

So I see no change in end result at this point, but the template was updated - I didn't have to move CLI versions in order to get to that point - so there was progress there

Hey all,

Spent most of the day on this, been a wild ride but I Android & iOS are now both back to working order on the template, so should just be able to follow the guide again: https://invertase.io/oss/react-native-firebase/quick-start/new-project

Please let me know how you get on, thanks

image

@Salakar Oh it's on!!

Screen Shot 2019-05-20 at 22 48 36

@matthieunelmes nice πŸŽ‰

You might be aware already but just in case; the warning just means you've not added any Firebase credentials yet but an API is being called for firebase (the analytics method in app.js) guide for adding credentials should be at the bottom of the new-projects quick start guide - here's the direct link: https://invertase-oss-rnfb.netlify.com/oss/react-native-firebase/quick-start/ios-firebase-credentials

Let me know on this issue if you have any further issues with getting started on the docs

(ignore that the title says Android :D it is actually for iOS - will get that fixed πŸ™ˆ )

@Salakar yeah I figured that much, I just got over excited and added the plist to the Xcode project, not the workspace.

Also, I think we need to amend the docs from:

@import Firebase.h;

to

#import <Firebase.h>

Also, I think we need to amend the docs from:

Hmm, this is the way the official Firebase docs recommend adding it - did it not work for you this way? I can update if it's not working

EDIT: Updated the docs now & is live: https://invertase-oss-rnfb.netlify.com/oss/react-native-firebase/quick-start/ios-firebase-credentials

Oh man, I was all excited to take a happy android screenshot to match your iOS success...but... :-(


terminal session for android template attempt


mike@isabela:~/work/react-random % npx @react-native-community/cli@next init  --template=@react-native-firebase/template@alpha firebaseanalyzertests

               ######                ######               
             ###     ####        ####     ###             
            ##          ###    ###          ##            
            ##             ####             ##            
            ##             ####             ##            
            ##           ##    ##           ##            
            ##         ###      ###         ##            
             ##  ########################  ##             
          ######    ###            ###    ######          
      ###     ##    ##              ##    ##     ###      
   ###         ## ###      ####      ### ##         ###   
  ##           ####      ########      ####           ##  
 ##             ###     ##########     ###             ## 
  ##           ####      ########      ####           ##  
   ###         ## ###      ####      ### ##         ###   
      ###     ##    ##              ##    ##     ###      
          ######    ###            ###    ######          
             ##  ########################  ##             
            ##         ###      ###         ##            
            ##           ##    ##           ##            
            ##             ####             ##            
            ##             ####             ##            
            ##          ###    ###          ##            
             ###     ####        ####     ###             
               ######                ######               


                  Welcome to React Native!                
                 Learn Once Write Anywhere                

βœ” Downloading template
βœ” Copying template
βœ” Processing template
βœ” Installing all required dependencies

  Run instructions for iOS:
    β€’ cd /home/mike/work/react-random && react-native run-ios
    - or -
    β€’ Open ../ios/firebaseanalyzertests.xcodeproj in Xcode
    β€’ Hit the Run button

  Run instructions for Android:
    β€’ Have an Android emulator running (quickest way to get started), or a device connected.
    β€’ cd /home/mike/work/react-random && react-native run-android

mike@isabela:~/work/react-random % cd firebaseanalyzertests/
mike@isabela:~/work/react-random/firebaseanalyzertests % cp ../firebaseanalyzertests-google-services.json android/app/google-services.json
mike@isabela:~/work/react-random/firebaseanalyzertests % npx @react-native-community/cli@next run-android
info JS server already running.
info Installing the app...
Starting a Gradle Daemon (subsequent builds will be faster)

> Configure project :@react-native-firebase_analytics
:@react-native-firebase_analytics:firebase.analytics using default value: 16.4.0
:@react-native-firebase_analytics:googlePlayServices.base using default value: 16.1.0
:@react-native-firebase_analytics package.json found at /home/mike/work/react-random/firebaseanalyzertests/node_modules/@react-native-firebase/analytics/package.json
:@react-native-firebase_analytics:version set from package.json: 6.0.0-alpha.16 (6,0,0 - 6000000)
:@react-native-firebase_analytics:android.compileSdk using custom value: 28
:@react-native-firebase_analytics:android.targetSdk using custom value: 28
:@react-native-firebase_analytics:android.minSdk using custom value: 16
:@react-native-firebase_analytics:reactNativeAndroidDir /home/mike/work/react-random/firebaseanalyzertests/node_modules/react-native/android

> Configure project :@react-native-firebase_app
:@react-native-firebase_app:firebase.core using default value: 16.0.9
:@react-native-firebase_app:firebase.common using default value: 16.1.0
:@react-native-firebase_app:googlePlayServices.base using default value: 16.1.0
:@react-native-firebase_app package.json found at /home/mike/work/react-random/firebaseanalyzertests/node_modules/@react-native-firebase/app/package.json
:@react-native-firebase_app:version set from package.json: 6.0.0-alpha.16 (6,0,0 - 6000000)
:@react-native-firebase_app:android.compileSdk using custom value: 28
:@react-native-firebase_app:android.targetSdk using custom value: 28
:@react-native-firebase_app:android.minSdk using custom value: 16
:@react-native-firebase_app:reactNativeAndroidDir /home/mike/work/react-random/firebaseanalyzertests/node_modules/react-native/android

> Configure project :app
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)

> Task :@react-native-firebase_app:compileDebugJavaWithJavac FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.2.1/userguide/command_line_interface.html#sec:command_line_warnings
16 actionable tasks: 16 executed
/home/mike/work/react-random/firebaseanalyzertests/node_modules/@react-native-firebase/app/android/src/main/java/io/invertase/firebase/common/ReactNativeFirebaseJSON.java:36: error: cannot find symbol
      jsonObject = new JSONObject(BuildConfig.FIREBASE_JSON_RAW);
                                             ^
  symbol:   variable FIREBASE_JSON_RAW
  location: class BuildConfig
1 error

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':@react-native-firebase_app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 10s

error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.

For iOS though, following the instructions, it works with no yellow box even. :fireworks:

The iOS bit is useful for me because I've got some sort of heap corruption going on in my app and on the rn-firebase 5.3.x series (with firebase-ios-sdk pods at 5.20.x) memory analysis shows problems immediately, but it's useless because the pods are out of date. Now I can start building a repro at least - thanks!

@Salakar Yeah I can't get the other import method to work. Although to be honest, I don't really know what I'm doing in Xcode and spend the vast majority of my time copy/pasta from tutorials.

@mikehardy oh wow - I know what this is but equally, it's not happening for me locally =/ let me dig into it a bit today, again πŸ™ˆ

@matthieunelmes Yeah I can't get the other import method to work.

Thanks; I'll update the docs

@mikehardy this should be fixed now. Out of interest are you on windows? This was an issue with the firebase.json file.

@Ehesp @Salakar works on android now! :muscle: - v6 is obviously a long path, but this is huge for me (an end user) - now I can easily play to test things (like auth, which I haven't looked at yet)

@thymikee there was one interesting thing (for me). You will need a google-services.json from firebase to do this (they are free at least) but the CLI works one way and fails the other for me on linux (Ubuntu 19.04 right now but shouldn't vary vs 18)

If you do:
npx @react-native-community/cli@next init --template=@react-native-firebase/template@alpha firebaseanalyzertests

it works, that part is excellent. Then I copy my Firebase credentials in:
cd firebaseanalyzertests/ && cp ../firebaseanalyzertests-google-services.json android/app/google-services.json

...again, no problems. But now if I go like this:
npx @react-native-community/cli@next start - it does this error when the app starts fetching the bundle:

mike@isabela:~/work/react-random/firebaseanalyzertests % npx @react-native-community/cli@next start
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                                                                              β”‚
β”‚  Running Metro Bundler on port 8081.                                         β”‚
β”‚                                                                              β”‚
β”‚  Keep Metro running while developing on any JS projects. Feel free to        β”‚
β”‚  close this tab and run your own Metro instance if you prefer.               β”‚
β”‚                                                                              β”‚
β”‚  https://github.com/facebook/react-native                                    β”‚
β”‚                                                                              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Looking for JS files in
   /home/mike/work/react-random/firebaseanalyzertests 

Loading dependency graph, done.
error: bundling failed: Error: Unable to resolve module `./../../../.npm/_npx/23897/lib/node_modules/@react-native-community/cli/node_modules/react-transform-hmr/lib/index.js` from `/home/mike/work/react-random/firebaseanalyzertests/App.js`: The module `./../../../.npm/_npx/23897/lib/node_modules/@react-native-community/cli/node_modules/react-transform-hmr/lib/index.js` could not be found from `/home/mike/work/react-random/firebaseanalyzertests/App.js`. Indeed, none of these files exist:
  * `/home/mike/.npm/_npx/23897/lib/node_modules/@react-native-community/cli/node_modules/react-transform-hmr/lib/index.js(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)`
  * `/home/mike/.npm/_npx/23897/lib/node_modules/@react-native-community/cli/node_modules/react-transform-hmr/lib/index.js/index(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)`
    at ModuleResolver.resolveDependency (/home/mike/.npm/_npx/27309/lib/node_modules/@react-native-community/cli/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:163:15)
    at ResolutionRequest.resolveDependency (/home/mike/.npm/_npx/27309/lib/node_modules/@react-native-community/cli/node_modules/metro/src/node-haste/DependencyGraph/ResolutionRequest.js:52:18)
    at DependencyGraph.resolveDependency (/home/mike/.npm/_npx/27309/lib/node_modules/@react-native-community/cli/node_modules/metro/src/node-haste/DependencyGraph.js:283:16)
    at Object.resolve (/home/mike/.npm/_npx/27309/lib/node_modules/@react-native-community/cli/node_modules/metro/src/lib/transformHelpers.js:262:42)
    at /home/mike/.npm/_npx/27309/lib/node_modules/@react-native-community/cli/node_modules/metro/src/DeltaBundler/traverseDependencies.js:399:31
    at Array.map (<anonymous>)
    at resolveDependencies (/home/mike/.npm/_npx/27309/lib/node_modules/@react-native-community/cli/node_modules/metro/src/DeltaBundler/traverseDependencies.js:396:18)
    at /home/mike/.npm/_npx/27309/lib/node_modules/@react-native-community/cli/node_modules/metro/src/DeltaBundler/traverseDependencies.js:269:33
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (/home/mike/.npm/_npx/27309/lib/node_modules/@react-native-community/cli/node_modules/metro/src/DeltaBundler/traverseDependencies.js:87:24)
 DELTA  [android, dev] ./index.js β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘ 0.0% (3/179), failed.

::ffff:127.0.0.1 - - [21/May/2019:16:57:18 +0000] "GET /index.delta?platform=android&dev=true&minify=false&revisionId=944783f0ba7599b3 HTTP/1.1" 500 - "-" "okhttp/3.12.1"

Maybe this is where my big reset button in react-native-clean-project would be useful? Though I tried to --reset-cache, and I tried to delete the /tmp/haste* stuff etc

When I do this:
./node_modules/.bin/react-native run-android

...everything is perfect

? :thinking:

@mikehardy looks like npx sets up some symlinks that Metro is not able to resolve (we observe the same behavior running start command locally.) For the time being, can you add @react-native-community/cli@next as your dev dependency and run from there? That should work just fine:

yarn add --dev @react-native-community/cli@next 
yarn react-native start

@thymikee in the template here for react-native-firebase v6 it is already set, so there is no real issue here (and apart from windows, I think they'll be able to close this issue in a bit). I just wanted to make sure you were aware of the problem (sounds like you are) since all the repro commands and logs are available. Sounds like you guys are on it

@mikehardy looks like npx sets up some symlinks that Metro is not able to resolve (we observe the same behavior running start command locally.) For the time being, can you add @react-native-community/cli@next as your dev dependency and run from there? That should work just fine:

yarn add --dev @react-native-community/cli@next 
yarn react-native start

@thymikee Is the latest RN cli setting up the correct symlinks? Can we use v6 without npx?
I'm going to try adding v6 to my app this week so any info is appreciated, thanks in advance!

@bondparkerbond - in fact, npx does not work (for me on android at least) but the CLI inside module works, specifically either ./node_modules/.bin/react-native run-android or yarn react-native start will start it up for me correctly

Using npx to create the the app from the template etc is fine, it's only using npx to run react native start that's the issue, you can just run that as normal instead without npx.

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.

For anyone else still having this issue: I was running into this when trying to install the template without the @alpha tag, but I made a PR to the cli that fixes it: https://github.com/react-native-community/cli/pull/497

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bitfabrikken picture bitfabrikken  Β·  52Comments

hapo-hoangnh picture hapo-hoangnh  Β·  52Comments

tranty9597 picture tranty9597  Β·  79Comments

OleksandrKucherenko picture OleksandrKucherenko  Β·  46Comments

TalEliel picture TalEliel  Β·  48Comments