invertase / react-native-firebase

🔥 A well-tested feature-rich modular Firebase implementation for React Native. Supports both iOS & Android platforms for all Firebase services.
https://rnfirebase.io
Other
11.7k stars 2.22k forks source link

🔥 You attempted to use a Firebase module that's not installed on your android project by calling firebase.app() #5551

Closed morghan102 closed 3 years ago

morghan102 commented 3 years ago

Issue

Describe your issue here This error is happening following the addition of firebaseAuth. Everything was working when I was using only the database. Now that I'm using Auth, I'm getting the above error. I appreciate any help in resolving it! This is only an andrid app right now.

Project Files

Javascript

Click To Expand

#### `package.json`: ```json { "scripts": { "start": "react-native start", "android": "react-native run-android", "ios": "react-native run-ios", "web": "expo start --web", "eject": "expo eject" }, "dependencies": { "@aws-sdk/client-cognito-identity": "^3.18.0", "@aws-sdk/client-s3": "^3.18.0", "@aws-sdk/credential-provider-cognito-identity": "^3.18.0", "@date/holidays-us": "^0.4.0", "@react-native-async-storage/async-storage": "~1.15.0", "@react-native-community/datetimepicker": "3.5.2", "@react-native-community/masked-view": "^0.1.11", "@react-native-community/netinfo": "6.0.0", "@react-native-firebase/app": "^12.3.0", "@react-native-firebase/auth": "^12.3.0", "@react-native-picker/picker": "1.16.1", "@react-navigation/material-top-tabs": "^5.3.15", "@react-navigation/native": "^5.9.4", "@react-navigation/stack": "^5.14.5", "axios": "^0.21.1", "body-parser": "^1.19.0", "connect-flash": "^0.1.1", "date-holidays": "^3.1.0", "dotenv": "^10.0.0", "expo": "^42.0.0", "expo-image-picker": "~10.2.2", "expo-mail-composer": "~10.2.2", "expo-notifications": "~0.12.3", "expo-permissions": "~12.1.1", "expo-secure-store": "~10.2.0", "expo-sms": "~9.2.3", "expo-splash-screen": "~0.6.2", "expo-status-bar": "~1.0.4", "expo-updates": "~0.3.2", "express": "^4.17.1", "express-validator": "^6.12.0", "firebase": "^8.8.0", "lottie-ios": "3.1.8", "lottie-react-native": "4.0.2", "moment": "^2.29.1", "mongoose": "^5.12.14", "morgan": "^1.10.0", "react": "16.13.1", "react-dom": "16.13.1", "react-file-base64": "^1.0.3", "react-native": "~0.63.3", "react-native-awesome-alerts": "^1.5.0", "react-native-calendar-picker": "^7.1.1", "react-native-collapsible": "^1.6.0", "react-native-collapsible-list": "^2.2.2", "react-native-elements": "^3.4.2", "react-native-gesture-handler": "^1.10.3", "react-native-modal-selector": "^2.0.3", "react-native-reanimated": "^2.2.0", "react-native-safe-area-context": "^3.2.0", "react-native-screens": "^3.4.0", "react-native-tab-view": "^2.16.0", "react-native-unimodules": "~0.11.0", "react-native-vector-icons": "^8.1.0", "react-native-view-more-text": "^2.1.0", "react-native-web": "~0.13.12", "react-navigation": "4", "react-navigation-stack": "^1.10.3", "react-navigation-tabs": "^2.11.1", "react-redux": "7.2.0", "redux": "4.0.5", "redux-logger": "3.0.6", "redux-thunk": "2.3.0" }, "devDependencies": { "@babel/core": "~7.9.0", "babel-jest": "~25.2.6", "jest": "~25.2.6", "react-test-renderer": "~16.13.1" }, "private": true, "name": "malspals", "version": "1.0.0" } ``` #### `firebase.json` for react-native-firebase v6: ```json # N/A ```

iOS

Click To Expand

#### `ios/Podfile`: - [ ] I'm not using Pods - [x] I'm using Pods and my Podfile looks like: ```ruby # N/A ``` #### `AppDelegate.m`: ```objc // N/A ```


Android

Click To Expand

#### Have you converted to AndroidX? - [ x] 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? #### `android/build.gradle`: ```groovy // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { ext { buildToolsVersion = "29.0.2" minSdkVersion = 21 compileSdkVersion = 29 targetSdkVersion = 29 } repositories { google() jcenter() } dependencies { classpath("com.android.tools.build:gradle:3.5.3") // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { mavenLocal() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url("$rootDir/../node_modules/react-native/android") } maven { // Android JSC is installed from npm url("$rootDir/../node_modules/jsc-android/dist") } google() jcenter() maven { url 'https://www.jitpack.io' } } } ``` #### `android/app/build.gradle`: ```groovy apply plugin: "com.android.application" import com.android.build.OutputFile /** * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets * and bundleReleaseJsAndAssets). * These basically call `react-native bundle` with the correct arguments during the Android build * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the * bundle directly from the development server. Below you can see all the possible configurations * and their defaults. If you decide to add a configuration block, make sure to add it before the * `apply from: "../../node_modules/react-native/react.gradle"` line. * * project.ext.react = [ * // the name of the generated asset file containing your JS bundle * bundleAssetName: "index.android.bundle", * * // the entry file for bundle generation. If none specified and * // "index.android.js" exists, it will be used. Otherwise "index.js" is * // default. Can be overridden with ENTRY_FILE environment variable. * entryFile: "index.android.js", * * // https://reactnative.dev/docs/performance#enable-the-ram-format * bundleCommand: "ram-bundle", * * // whether to bundle JS and assets in debug mode * bundleInDebug: false, * * // whether to bundle JS and assets in release mode * bundleInRelease: true, * * // whether to bundle JS and assets in another build variant (if configured). * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants * // The configuration property can be in the following formats * // 'bundleIn${productFlavor}${buildType}' * // 'bundleIn${buildType}' * // bundleInFreeDebug: true, * // bundleInPaidRelease: true, * // bundleInBeta: true, * * // whether to disable dev mode in custom build variants (by default only disabled in release) * // for example: to disable dev mode in the staging build type (if configured) * devDisabledInStaging: true, * // The configuration property can be in the following formats * // 'devDisabledIn${productFlavor}${buildType}' * // 'devDisabledIn${buildType}' * * // the root of your project, i.e. where "package.json" lives * root: "../../", * * // where to put the JS bundle asset in debug mode * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", * * // where to put the JS bundle asset in release mode * jsBundleDirRelease: "$buildDir/intermediates/assets/release", * * // where to put drawable resources / React Native assets, e.g. the ones you use via * // require('./image.png')), in debug mode * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", * * // where to put drawable resources / React Native assets, e.g. the ones you use via * // require('./image.png')), in release mode * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", * * // by default the gradle tasks are skipped if none of the JS files or assets change; this means * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to * // date; if you have any other folders that you want to ignore for performance reasons (gradle * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ * // for example, you might want to remove it from here. * inputExcludes: ["android/**", "ios/**"], * * // override which node gets called and with what additional arguments * nodeExecutableAndArgs: ["node"], * * // supply additional arguments to the packager * extraPackagerArgs: [] * ] */ project.ext.react = [ enableHermes: false ] apply from: '../../node_modules/react-native-unimodules/gradle.groovy' apply from: "../../node_modules/react-native/react.gradle" apply from: "../../node_modules/expo-updates/scripts/create-manifest-android.gradle" /** * Set this to true to create two separate APKs instead of one: * - An APK that only works on ARM devices * - An APK that only works on x86 devices * The advantage is the size of the APK is reduced by about 4MB. * Upload all the APKs to the Play Store and people will download * the correct one based on the CPU architecture of their device. */ def enableSeparateBuildPerCPUArchitecture = false /** * Run Proguard to shrink the Java bytecode in release builds. */ def enableProguardInReleaseBuilds = false /** * The preferred build flavor of JavaScriptCore. * * For example, to use the international variant, you can use: * `def jscFlavor = 'org.webkit:android-jsc-intl:+'` * * The international variant includes ICU i18n library and necessary data * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that * give correct results when using with locales other than en-US. Note that * this variant is about 6MiB larger per architecture than default. */ def jscFlavor = 'org.webkit:android-jsc:+' /** * Whether to enable the Hermes VM. * * This should be set on project.ext.react and mirrored here. If it is not set * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode * and the benefits of using Hermes will therefore be sharply reduced. */ def enableHermes = project.ext.react.get("enableHermes", false); android { compileSdkVersion rootProject.ext.compileSdkVersion compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } defaultConfig { applicationId 'com.malspals' minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode 1 versionName "1.0.0" } splits { abi { reset() enable enableSeparateBuildPerCPUArchitecture universalApk false // If true, also generate a universal APK include "armeabi-v7a", "x86", "arm64-v8a", "x86_64" } } signingConfigs { debug { storeFile file('debug.keystore') storePassword 'android' keyAlias 'androiddebugkey' keyPassword 'android' } } buildTypes { debug { signingConfig signingConfigs.debug } release { // Caution! In production, you need to generate your own keystore file. // see https://reactnative.dev/docs/signed-apk-android. signingConfig signingConfigs.debug minifyEnabled enableProguardInReleaseBuilds proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" } } // applicationVariants are e.g. debug, release applicationVariants.all { variant -> variant.outputs.each { output -> // For each separate APK per architecture, set a unique version code as described here: // https://developer.android.com/studio/build/configure-apk-splits.html def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4] def abi = output.getFilter(OutputFile.ABI) if (abi != null) { // null for the universal-debug, universal-release variants output.versionCodeOverride = versionCodes.get(abi) * 1048576 + defaultConfig.versionCode } } } } dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) //noinspection GradleDynamicVersion implementation "com.facebook.react:react-native:+" // From node_modules implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0" debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") { exclude group:'com.facebook.fbjni' } debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") { exclude group:'com.facebook.flipper' exclude group:'com.squareup.okhttp3', module:'okhttp' } debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") { exclude group:'com.facebook.flipper' } addUnimodulesDependencies() if (enableHermes) { def hermesPath = "../../node_modules/hermes-engine/android/"; debugImplementation files(hermesPath + "hermes-debug.aar") releaseImplementation files(hermesPath + "hermes-release.aar") } else { implementation jscFlavor } } // Run this once to be able to run the application with BUCK // puts all compile dependencies into folder libs for BUCK to use task copyDownloadableDepsToLibs(type: Copy) { from configurations.compile into 'libs' } apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) ``` #### `android/settings.gradle`: ```groovy rootProject.name = 'malspals' apply from: '../node_modules/react-native-unimodules/gradle.groovy' includeUnimodulesProjects() apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) include ':app' ``` #### `MainApplication.java`: ```java package com.malspals; import android.app.Application; import android.content.Context; import android.net.Uri; import com.facebook.react.PackageList; import com.facebook.react.ReactApplication; import com.facebook.react.ReactInstanceManager; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; import com.facebook.react.shell.MainReactPackage; import com.facebook.soloader.SoLoader; import com.malspals.generated.BasePackageList; import org.unimodules.adapters.react.ReactAdapterPackage; import org.unimodules.adapters.react.ModuleRegistryAdapter; import org.unimodules.adapters.react.ReactModuleRegistryProvider; import org.unimodules.core.interfaces.Package; import org.unimodules.core.interfaces.SingletonModule; import expo.modules.constants.ConstantsPackage; import expo.modules.permissions.PermissionsPackage; import expo.modules.filesystem.FileSystemPackage; import expo.modules.updates.UpdatesController; import java.lang.reflect.InvocationTargetException; import java.util.Arrays; import java.util.List; import javax.annotation.Nullable; public class MainApplication extends Application implements ReactApplication { private final ReactModuleRegistryProvider mModuleRegistryProvider = new ReactModuleRegistryProvider( new BasePackageList().getPackageList() ); private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { @Override public boolean getUseDeveloperSupport() { return BuildConfig.DEBUG; } @Override protected List getPackages() { List packages = new PackageList(this).getPackages(); packages.add(new ModuleRegistryAdapter(mModuleRegistryProvider)); return packages; } @Override protected String getJSMainModuleName() { return "index"; } @Override protected @Nullable String getJSBundleFile() { if (BuildConfig.DEBUG) { return super.getJSBundleFile(); } else { return UpdatesController.getInstance().getLaunchAssetFile(); } } @Override protected @Nullable String getBundleAssetName() { if (BuildConfig.DEBUG) { return super.getBundleAssetName(); } else { return UpdatesController.getInstance().getBundleAssetName(); } } }; @Override public ReactNativeHost getReactNativeHost() { return mReactNativeHost; } @Override public void onCreate() { super.onCreate(); SoLoader.init(this, /* native exopackage */ false); if (!BuildConfig.DEBUG) { UpdatesController.initialize(this); } initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); } /** * Loads Flipper in React Native templates. Call this in the onCreate method with something like * initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); * * @param context * @param reactInstanceManager */ private static void initializeFlipper( Context context, ReactInstanceManager reactInstanceManager) { if (BuildConfig.DEBUG) { try { /* We use reflection here to pick up the class that initializes Flipper, since Flipper library is not available in release mode */ Class aClass = Class.forName("com.malspals.ReactNativeFlipper"); aClass .getMethod("initializeFlipper", Context.class, ReactInstanceManager.class) .invoke(null, context, reactInstanceManager); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } } } } ``` #### `AndroidManifest.xml`: ```xml ```


Environment

Click To Expand

**`react-native info` output:** ``` info Fetching system and libraries information... (node:197294) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency (Use `node --trace-warnings ...` to show where the warning was created) System: OS: Linux 5.8 Ubuntu 20.04.2 LTS (Focal Fossa) CPU: (4) x64 Intel(R) Core(TM) i5-6300U CPU @ 2.40GHz Memory: 474.22 MB / 7.67 GB Shell: 5.0.17 - /bin/bash Binaries: Node: 14.9.0 - ~/.nvm/versions/node/v14.9.0/bin/node Yarn: 1.22.10 - ~/.nvm/versions/node/v14.9.0/bin/yarn npm: 7.18.1 - ~/.nvm/versions/node/v14.9.0/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: Android SDK: Not Found IDEs: Android Studio: 4.1 AI-201.8743.12.41.7199119 Languages: Java: 11.0.11 - /usr/bin/javac Python: 2.7.18 - /usr/bin/python npmPackages: @react-native-community/cli: Not Found react: 16.13.1 => 16.13.1 react-native: ~0.63.3 => 0.63.4 npmGlobalPackages: *react-native*: Not Found``` - **Platform that you're experiencing the issue on**: - [ ] iOS - [x ] Android - [ ] **iOS** but have not tested behavior on Android - [x ] **Android** but have not tested behavior on iOS - [ ] Both - **`react-native-firebase` version you're using that has this issue:** - Unsure, cannot find. - **`Firebase` module(s) you're using that has the issue:** - `firebase.app()` - **Are you using `TypeScript`?** - N


mikehardy commented 3 years ago

Most strange - you mention "everything was working when I was using only the database" but I don't see that in your dependencies?


    "@react-native-firebase/app": "^12.3.0",
    "@react-native-firebase/auth": "^12.3.0",

?

I would triple-check you have everything installed that you intend, then worst case do an npx react-native-clean-project (warning: this works great but does blow out caches so requires re-downloads of quite a bit afterwards, in case your not on a good connection when you do it...)

morghan102 commented 3 years ago

Thank you for the suggestion! However, I just tried it and it didn't work. I got a bunch of errors with running that command:

Need to install the following packages:
  react-native-clean-project
Ok to proceed? (y) y
Wipe iOS build folder? (Y/n) y
Wipe iOS Pods folder? (Y/n) y
Wipe system iOS Pods cache? (Y/n) y
Wipe user iOS Pods cache? (Y/n) y
Update pods? (Y/n) y
Wipe android build folder? (Y/n) y
Clean Android project? (Y/n) y
Wipe node_modules folder? (Y/n) y
Update brew? (Y/n) y
Error running 'wipe iOS build artifacts': Xcode: no process found
/bin/sh: 1: xcrun: not found

Error running 'wipe system iOS Pods cache': /bin/sh: 1: pod: not found

Error running 'brew update': /bin/sh: 1: brew: not found

❌  Command 'wipe iOS build artifacts' failed with code: 127
(node:222828) UnhandledPromiseRejectionWarning: undefined
(Use `node --trace-warnings ...` to show where the warning was created)
(node:222828) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:222828) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
✅  wipe iOS Pods folder task has finished running in 46ms.
❌  Command 'wipe system iOS Pods cache' failed with code: 127
(node:222828) UnhandledPromiseRejectionWarning: undefined
(node:222828) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
✅  wipe user iOS Pods cache task has finished running in 40ms.
✅  wipe android build folder task has finished running in 39ms.
✅  watchman cache clear (if watchman is installed) task has finished running in 34ms.
✅  wipe temporary caches task has finished running in 33ms.
❌  Command 'brew update' failed with code: 127
❌ Skipping task 'brew upgrade' because there was an error with 'brew update'
✅  wipe node_modules task has finished running in 3s.
Error running 'yarn cache clean (if yarn is installed)': warning ../../../../package.json: No license field

Error running 'clean android project': 

Error running 'clean android project': FAILURE: Build failed with an exception.

* Where:

Error running 'clean android project': Settings file '/home/user/morghan/nucamp/4-React-Native/malspals/android/settings.gradle' line: 3

* What went wrong:
A problem occurred evaluating settings 'malspals'.
> Could not read script '/home/user/morghan/nucamp/4-React-Native/malspals/node_modules/react-native-unimodules/gradle.groovy' as it does not exist.

* 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 8s

❌  Command 'clean android project' failed with code: 1
(node:222828) UnhandledPromiseRejectionWarning: undefined
(node:222828) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3)
✅  yarn cache clean (if yarn is installed) task has finished running in 24s.
✅  npm cache verify task has finished running in 16s.
Error running 'npm ci': npm
Error running 'npm ci':  ERR! code ERESOLVE

Error running 'npm ci': npm 
Error running 'npm ci': ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! Found: react-native-screens@3.4.0
npm ERR! node_modules/react-native-screens

Error running 'npm ci': npm ERR!   react-native-screens@"^3.4.0" from the root project
npm ERR!   peer react-native-screens@">=1.0.0 || >= 2.0.0-alpha.0 || >= 2.0.0-beta.0 || >= 2.0.0" from react-navigation-tabs@2.11.1
npm ERR!   node_modules/react-navigation-tabs
npm
Error running 'npm ci':  ERR!     react-navigation-tabs@"^2.11.1" from the root project
npm ERR!   1 more (@react-navigation/stack)
npm ERR! 
npm ERR!
Error running 'npm ci':  Could not resolve dependency:
npm ERR! peer react-native-screens@"^1.0.0 || ^1.0.0-alpha" from react-navigation-stack@1.10.3
npm ERR! node_modules/react-navigation-stack
npm ERR!
Error running 'npm ci':    react-navigation-stack@"^1.10.3" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps

Error running 'npm ci': npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! See /home/user/.npm/eresolve-report.txt for a full report.

Error running 'npm ci': 

Error running 'npm ci': npm ERR! A complete log of this run can be found in:
npm ERR!     /home/user/.npm/_logs/2021-07-28T15_46_54_181Z-debug.log

✅  npm ci task has finished running in 6s.
Error running 'yarn install (if yarn is installed)': warning ../../../../package.json: No license field

Error running 'yarn install (if yarn is installed)': warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.

Error running 'yarn install (if yarn is installed)': warning "expo > babel-preset-expo > @babel/preset-env > @babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining@7.13.12" has incorrect peer dependency "@babel/core@^7.13.0".

Error running 'yarn install (if yarn is installed)': warning " > react-file-base64@1.0.3" has incorrect peer dependency "react@^15.0.2".

Error running 'yarn install (if yarn is installed)': warning " > react-native-view-more-text@2.1.0" has unmet peer dependency "prop-types@^15.5.7".

Error running 'yarn install (if yarn is installed)': warning " > react-navigation-stack@1.10.3" has incorrect peer dependency "react-native-screens@^1.0.0 || ^1.0.0-alpha".

Error running 'yarn install (if yarn is installed)': warning " > react-navigation-tabs@2.11.1" has incorrect peer dependency "react-native-reanimated@^1.0.0-alpha".

✅  yarn install (if yarn is installed) task has finished running in 58s.
Error running 'update iOS Pods': /bin/sh: 1: pod: not found

❌  Command 'update iOS Pods' failed with code: 127
❌  Examine output - error in either yarn cache clean, yarn install, or pod update
morghan102 commented 3 years ago

I tried starting my app again and got the same error.

mikehardy commented 3 years ago

And yet, this works? https://github.com/mikehardy/rnfbdemo/blob/master/make-demo.sh (or it did last I checked it - it attempts to use the current version of everything and sometimes needs adjustment)

If you examine that script and it's output - somewhere between what it does + produces and your project is the problem I think, this process of comparison has helped a lot of people solve their issues

morghan102 commented 3 years ago

I'm thinking this has to be a bug or the way I have everything set up, as every time I fix a small error there's another one. It looks like I have to manually integrate React Native Firebase into my Android app (following this), which I just tried but may have done incorrectly. I followed the other steps successfully except the last one, as I already had packages in this part of MainApplication.java: original in MainApplication.java

    @Override
    protected List<ReactPackage> getPackages() {
      List<ReactPackage> packages = new PackageList(this).getPackages();
      packages.add(new ModuleRegistryAdapter(mModuleRegistryProvider));
      return packages;
    }

And I tried these 2 setups

    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.asList(
      new MainReactPackage(),
      new ReactNativeFirebaseAppPackage(),
      );
      List<ReactPackage> packages = new PackageList(this).getPackages();
      packages.add(new ModuleRegistryAdapter(mModuleRegistryProvider));
      return packages;
    }

and

    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.asList(
      new MainReactPackage(),
      new ReactNativeFirebaseAppPackage(),

      List<ReactPackage> packages = new PackageList(this).getPackages();
      packages.add(new ModuleRegistryAdapter(mModuleRegistryProvider));
      return packages;
      );    
      }
mikehardy commented 3 years ago

There is no need to manually integrate firebase following those instructions in any modern react-native version (0.60 or greater)

That file (the make-demo.sh) script is something you can run. It's a shell script. Or you may read it. What it does is start from scracth (npx react-native init rnfbdemo) and then - programmatically - it does every step required to have a functioning react-native-firebase app running, along with crashlytics and performance integrations even, then it test compiles the app to prove it works.

It works?

duylinhdang1998 commented 3 years ago

+1 the same error

mikehardy commented 3 years ago

@duylinhdang1998 how'd it go when you tried https://github.com/mikehardy/rnfbdemo/blob/master/make-demo.sh ?

morghan102 commented 3 years ago

Running the script didn't work! Here's the output:

> Task :app:installRelease FAILED
281 actionable tasks: 281 executed
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /home/user/morghan/repoclone/rnfbdemo/rnfbdemo/node_modules/@react-native-firebase/analytics/android/src/main/java/io/invertase/firebase/analytics/UniversalFirebaseAnalyticsModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /home/user/morghan/repoclone/rnfbdemo/rnfbdemo/node_modules/@react-native-firebase/auth/android/src/main/java/io/invertase/firebase/auth/ReactNativeFirebaseAuthModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /home/user/morghan/repoclone/rnfbdemo/rnfbdemo/node_modules/@react-native-firebase/database/android/src/reactnative/java/io/invertase/firebase/database/ReactNativeFirebaseDatabaseCommon.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: /home/user/morghan/repoclone/rnfbdemo/rnfbdemo/node_modules/@react-native-firebase/dynamic-links/android/src/main/java/io/invertase/firebase/dynamiclinks/ReactNativeFirebaseDynamicLinksModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: /home/user/morghan/repoclone/rnfbdemo/rnfbdemo/node_modules/@react-native-firebase/functions/android/src/main/java/io/invertase/firebase/functions/UniversalFirebaseFunctionsModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /home/user/morghan/repoclone/rnfbdemo/rnfbdemo/node_modules/@react-native-firebase/in-app-messaging/android/src/main/java/io/invertase/firebase/fiam/UniversalFirebaseFiamModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /home/user/morghan/repoclone/rnfbdemo/rnfbdemo/node_modules/@react-native-firebase/messaging/android/src/main/java/io/invertase/firebase/messaging/ReactNativeFirebaseMessagingModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /home/user/morghan/repoclone/rnfbdemo/rnfbdemo/node_modules/@react-native-firebase/perf/android/src/main/java/io/invertase/firebase/perf/UniversalFirebasePerfModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /home/user/morghan/repoclone/rnfbdemo/rnfbdemo/node_modules/@react-native-firebase/remote-config/android/src/main/java/io/invertase/firebase/config/UniversalFirebaseConfigModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:installRelease'.
> java.util.concurrent.ExecutionException: org.gradle.api.GradleException: Failed to install on any devices.

* 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 4m 57s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: ./gradlew app:installRelease -PreactNativeDevServerPort=8081
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /home/user/morghan/repoclone/rnfbdemo/rnfbdemo/node_modules/@react-native-firebase/analytics/android/src/main/java/io/invertase/firebase/analytics/UniversalFirebaseAnalyticsModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /home/user/morghan/repoclone/rnfbdemo/rnfbdemo/node_modules/@react-native-firebase/auth/android/src/main/java/io/invertase/firebase/auth/ReactNativeFirebaseAuthModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /home/user/morghan/repoclone/rnfbdemo/rnfbdemo/node_modules/@react-native-firebase/database/android/src/reactnative/java/io/invertase/firebase/database/ReactNativeFirebaseDatabaseCommon.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: /home/user/morghan/repoclone/rnfbdemo/rnfbdemo/node_modules/@react-native-firebase/dynamic-links/android/src/main/java/io/invertase/firebase/dynamiclinks/ReactNativeFirebaseDynamicLinksModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: /home/user/morghan/repoclone/rnfbdemo/rnfbdemo/node_modules/@react-native-firebase/functions/android/src/main/java/io/invertase/firebase/functions/UniversalFirebaseFunctionsModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /home/user/morghan/repoclone/rnfbdemo/rnfbdemo/node_modules/@react-native-firebase/in-app-messaging/android/src/main/java/io/invertase/firebase/fiam/UniversalFirebaseFiamModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /home/user/morghan/repoclone/rnfbdemo/rnfbdemo/node_modules/@react-native-firebase/messaging/android/src/main/java/io/invertase/firebase/messaging/ReactNativeFirebaseMessagingModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /home/user/morghan/repoclone/rnfbdemo/rnfbdemo/node_modules/@react-native-firebase/perf/android/src/main/java/io/invertase/firebase/perf/UniversalFirebasePerfModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /home/user/morghan/repoclone/rnfbdemo/rnfbdemo/node_modules/@react-native-firebase/remote-config/android/src/main/java/io/invertase/firebase/config/UniversalFirebaseConfigModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:installRelease'.
> java.util.concurrent.ExecutionException: org.gradle.api.GradleException: Failed to install on any devices.

* 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 4m 57s

    at makeError (/home/user/morghan/repoclone/rnfbdemo/rnfbdemo/node_modules/execa/index.js:174:9)
    at /home/user/morghan/repoclone/rnfbdemo/rnfbdemo/node_modules/execa/index.js:278:16
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async runOnAllDevices (/home/user/morghan/repoclone/rnfbdemo/rnfbdemo/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:5)
    at async Command.handleAction (/home/user/morghan/repoclone/rnfbdemo/rnfbdemo/node_modules/@react-native-community/cli/build/index.js:186:9)
info Run CLI with --verbose flag for more details.
mikehardy commented 3 years ago

This appears outside the scope of a script, you appear to have a tooling issue on the android side:

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.

(emphasis added)

That said, the script sometimes needs some touch-ups as it just blindly uses "current everything" on purpose, but occasionally there's a necessary forward port. I'll re-try it myself since I haven't checked it in a while to make sure it succeeds. In the meantime, if you get your android environment square you should be able to just cd into the rnfbdemo directory now and run yarn android or similar, as the integration is all done by the time it attempts to do test release builds etc

morghan102 commented 3 years ago

Ok, thank you! Could it potentially be a Gradle problem? I see that on the output too.

mikehardy commented 3 years ago

I hesitate to speculate as it kind of could be anything. There are so very many things that are needed for react-native apps to be working well. I have an entire script that does nothing but "converge" (that is: test for tools and versions and bring them all up to date) on my colleague's machines that are less DevOps / sysadmin oriented as I am

Behold doctor.sh - please note I AM NOT ADVOCATING YOU RUN THIS, it will do it's best to install a lot of software on your machine in specific ways. It may do things you don't want. It's just an example of all the things I check and make sure are configured in teams I work with, and chunks of it may be useful in this instance

#!/bin/bash
#
# makes sure you are all set to develop, can be re-run at any time
#
set -e # Error out if there were any problems

# This is the block of versions we try to verify:
XCODE_WANTED_VERSION="Xcode 12"
XCODE_WANTED_VERSION_COMPLETE="${XCODE_WANTED_VERSION}.5.1"
BREW_WANTED_VERSION="3.2.3" # https://github.com/Homebrew/brew/releases
NVM_VERSION="0.38.0" # https://github.com/nvm-sh/nvm/releases
NODE_CURRENT_VERSION="v14.17.3" # https://nodejs.org/download/release/latest-v14.x/
YARN_VERSION="1.22.10" # https://github.com/yarnpkg/yarn/releases
RVM_VERSION_WANTED="1.29.12" # https://github.com/rvm/rvm/releases
RUBY_VERSION_WANTED="ruby-3.0.2" # https://www.ruby-lang.org/en/downloads/
FASTLANE_VERSION_WANTED="2.188.0" # https://github.com/fastlane/fastlane/releases
COCOAPODS_VERSION_WANTED="1.10.1" # https://github.com/CocoaPods/CocoaPods/releases
R_VERSION_WANTED="4." # https://www.r-project.org/
AVM_INSTALL="false"
NVM_INSTALL="false"
# Also check links to platform-specific libraries in ios/Podfile and android/build.gradle
# Also check gradle in android/app/gradle/gradle-wrapper.properties - https://gradle.org/releases/
# Also check firebase-android-sdk in android/build.gradle - https://firebase.google.com/support/release-notes/android
# Also check firebase-ios-sdk in ios/Podfile - https://firebase.google.com/support/release-notes/ios

# If the keychain is unlocked then this fails in the middle, let's check that now and fail fast
if [ "$(uname)" == "Darwin" ]; then
  if ! security show-keychain-info login.keychain > /dev/null 2>&1; then
    echo "Login keychain is not unlocked, decrypting fastlane certificates and installing is not possible"
    echo "run 'security unlock-keychain login.keychain' to unlock the login keychain then re-run doctor"
    exit 1
  fi
fi

# Xcode first, as other tools use it to compile things
# Check Xcode status optionally (brew might use it to build things later)
if [ "$(uname)" == "Darwin" ]; then
  echo "Verifying Xcode installation (want $XCODE_WANTED_VERSION_COMPLETE)"
  if ! XCODE_VERSION=$(xcodebuild -version|grep Xcode|cut -f1 -d'.') || [ "$XCODE_VERSION" != "$XCODE_WANTED_VERSION" ]; then
    echo "Xcode not installed or not correct version, got $XCODE_VERSION, expected $XCODE_WANTED_VERSION_COMPLETE"
    echo "Open the App Store app, and either install or update Xcode to $XCODE_WANTED_VERSION_COMPLETE"
    echo "If you are sure you have Xcode installed but it says you have a CommandLineTools intance, do 'sudo xcode-select -r' to fix"
    exit 1
  fi
  XCODE_VERSION=$(xcodebuild -version|grep Xcode)
  if [ "$XCODE_VERSION" != "$XCODE_WANTED_VERSION_COMPLETE" ]; then
    echo
    echo !!!!!!!!!!!!!!!!!!!!!!!!!!!
    echo
    echo "I know Xcode takes a long time to upgrade so this is just a warning, but"
    echo
    echo "Current Xcode version is $XCODE_WANTED_VERSION_COMPLETE, your version is $XCODE_VERSION"
    echo
    echo !!!!!!!!!!!!!!!!!!!!!!!!!!!
    echo
  fi
fi

# Now brew - may need to move this after ruby, but up to macOS 10.15 at least system ruby can install brew
if [ "$(uname)" == "Darwin" ]; then
  if [ $BREW_WANTED_VERSION == "2.6.2" ]; then
    echo ""
    echo "*******************************************************************"
    echo ""
    echo "  If brew complains about 'shallow clones' you must manually run the commands it suggests."
    echo "  The commands are SLOW and transfer a LOT of data."
    echo "  They must complete successfully before continuing"
    echo ""
    echo "*******************************************************************"
    echo ""
  fi
  echo "Verifying brew installation (want $BREW_WANTED_VERSION)"
  if ! BREW_VERSION=$(brew --version |grep 'Homebrew ') || [[ "$BREW_VERSION" != *"$BREW_WANTED_VERSION"* ]]; then
    echo "brew version was $BREW_VERSION, expected $BREW_WANTED_VERSION"
    echo "brew either not installed or not correct version, installing brew (you will be prompted for your password)";
    sudo echo "Running a sudo command in case of noninteractive terminals on macOS" > /dev/null 2>&1
    CI=true /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
  fi
  echo " - Upgrading brew installed programs (this may prompt you for your password)..."
  brew upgrade
  brew upgrade --cask
  brew cleanup

  echo "Verifying git configuration"
  if ! git config --get user.name > /dev/null; then
    read -rp "Enter git name (e.g. 'Mike Hardy'): " GIT_NAME; echo "$GIT_NAME"
    read -rp "Enter git email (e.g. 'mike@komp.ai'): " GIT_EMAIL; echo "$GIT_EMAIL"
    git config --global user.name "$GIT_NAME"
    git config --global user.email "$GIT_EMAIL"
    git config --global alias.co checkout
    echo "If you want to GPG sign your commits, set gpgsign true and ~/.gnupg/gpg-agent.conf to use pinentry-mac"
  fi

  echo "Verifying development utilities installation"
  for UTILITY in coreutils jq watchman gnupg pinentry-mac bash-completion applesimutils r; do
    if ! brew list --formula | grep "$UTILITY" > /dev/null; then
      echo "Development utility $UTILITY not installed, installing it..."
      if [ "$UTILITY" = "applesimutils" ]; then
        brew tap wix/brew
      fi
      brew install $UTILITY
    fi
  done
fi

echo "Verifying python scoring installation for lambda package"
if [ "$(uname)" == "Darwin" ]; then
  echo "Verifying mac python development utilities installation"
  for UTILITY in llvm gcc r; do
    if ! brew list --formula | grep "$UTILITY" > /dev/null; then
      echo "Python development utility $UTILITY not installed, installing it..."
      brew install $UTILITY
      if [ "$UTILITY" = "gcc" ]; then
        # gcc needs a symlink to work correctly
        rm -f /usr/local/bin/gcc
        ln -s /usr/local/bin/gcc-10 /usr/local/bin/gcc
        # gcc does not resolve correctly in PATH until Terminal restarted?
        echo ""
        echo "*******************************************************************"
        echo ""
        echo "  Brew package 'gcc' installed for first time."
        echo "  This command does not work correctly until Terminal is restarted"
        echo "  Exit this Terminal, open a new Terminal, re-run doctor.sh to continue."
        echo ""
        echo "*******************************************************************"
        echo ""
        exit 1
      fi
    fi
  done
fi

# Python and ML ecosystem are still in a poor state on Apple Silicon M1 macs...skip it
if ! [ "$(arch)" == "arm64" ]; then
  echo "Verifying python virtual environment installation"
  if ! [ -d "packages/lambda/virtualenv" ]; then
    echo "Python virtual environment did not exist for lambda package. Creating it..."
    pushd packages/lambda || (echo "Unable to change directory to packages/lambda" && exit 1)
    python3 -m venv virtualenv
    popd || (echo "Unable to return to previous directory" && exit 1)
  fi
  # shellcheck disable=SC1091
  source packages/lambda/virtualenv/bin/activate
  for UTILITY in wheel pandas sklearn packaging rpy2 tzlocal pipupgrade; do
    # FIXME Not upgrading these after the first installation.
    if ! pip list 2>/dev/null | grep "$UTILITY" > /dev/null 2>&1; then
      echo "Python library $UTILITY not installed, installing it..."
      pip install $UTILITY
    fi
    if [ "$UTILITY" = "pandas" ]; then
      # We have a special need to bring pandas over 1.0 if it is not already
      echo "Verifying pandas python library version >= 1.0.0"
      if ! PANDAS_VERSION=$(pip list 2>/dev/null |grep 'pandas ') || [[ "$PANDAS_VERSION" != *" 1."* ]]; then
        echo "Pandas python library wrong version, wanted 1+, got $PANDAS_VERSION"
        pipupgrade --latest --yes
      fi
    fi
  done
fi

echo "Verifying R installation"
if ! R_VERSION=$(R --version 2>&1 |grep 'R version'|cut -f3 -d' ') || [[ "$R_VERSION" != "$R_VERSION_WANTED"* ]]; then
  echo "R version not correct, wanted $R_VERSION_WANTED got $R_VERSION"
  if [ "$(uname)" == "Darwin" ]; then
    brew install R
  else
    echo "Please install R on this system manually"
    echo "For Ubuntu 20 consult https://rtask.thinkr.fr/installation-of-r-4-0-on-ubuntu-20-04-lts-and-tips-for-spatial-packages/"
    echo "It maybe looks like this: "
    echo "  for Ubuntu 20, this is how you get R v4.x https://rtask.thinkr.fr/installation-of-r-4-0-on-ubuntu-20-04-lts-and-tips-for-spatial-packages/"
    echo "  apt-get purge r-base* r-recommended r-cran-*"
    echo "  apt autoremove"
    echo "  apt update"
    echo "  apt upgrade"
    echo "  add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/'"
    echo "  sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9"
    echo "  sudo apt update"
    echo "  apt install r-base r-base-core r-recommended r-base-dev r-cran-littler"
    echo "  r --version"
    exit 1
  fi
fi
# shellcheck disable=SC2043
for UTILITY in gbm; do
   # FIXME Not upgrading these after the first installation.
   if ! Rscript -e 'installed.packages()'|grep $UTILITY|grep "$R_VERSION_WANTED" > /dev/null 2>&1; then
     echo "R library gbm not installed, installing it..."
     if ! Rscript -e 'install.packages("gbm", repos="https://cran.rstudio.com")'; then
       echo "Problem installing GBM package for R (used by lambda package to calculate scores)"
       echo "Maybe needs to run via sudo? like: sudo Rscript -e 'install.packages(\"gbm\", repos=\"https://cran.rstudio.com\")'"
       exit 1
     fi
   fi
done

echo "Verifying nvm (Node Version Manager) installation. (want $NVM_VERSION)"
export NVM_DIR="$HOME/.nvm"
    # shellcheck disable=SC1091
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
    # shellcheck disable=SC1091
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
if ! NVM_LIVE_VERSION=$(nvm --version 2>/dev/null) || [ "$NVM_LIVE_VERSION" != "$NVM_VERSION" ]; then
  echo "nvm (the Node Version Manager) missing or outdated, installing it."
  echo "##################################################################"
  curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v$NVM_VERSION/install.sh | bash
  export NVM_DIR="$HOME/.nvm"
    # shellcheck disable=SC1091
  [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
    # shellcheck disable=SC1091
  [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
  echo "##################################################################"
  NVM_INSTALL="true"
fi

# Install automatic node version management
echo "Verifying avm (Automatic NVM Management) installation."
if ! [ -e "$HOME/.nvm/auto-nvm.sh" ]; then
  echo "Automatic node.js version switching not enabled, enabling it."
  cp scripts/nvm-auto.sh "$HOME/.nvm/auto-nvm.sh"
  echo ". \$HOME/.nvm/auto-nvm.sh" >> "$HOME/.bash_profile"
  AVM_INSTALL="true"
fi

echo "Verifying current node.js is installed. (want $NODE_CURRENT_VERSION)"
if ! nvm use $NODE_CURRENT_VERSION >/dev/null 2>&1; then
  echo "Current node.js missing or outdated, installing it."
  nvm install $NODE_CURRENT_VERSION
  npm -g install yarn@^$YARN_VERSION
  if [ "$(uname)" == "Darwin" ]; then
    \rm -fr ~/Library/Developer/Xcode/DerivedData/ios-deploy-* && npm -g install ios-deploy@beta
  fi
fi
echo " - Upgrading current node.js global packages"
npm -g update
nvm alias default v14 > /dev/null

# Check mac file handles - TODO but I have a gist for how to install the patch

# Check linux file handles
# cat /proc/sys/fs/inotify/max_user_watches  (should be 524288)
# sudo echo 'fs.inotify.max_user_watches=524288' >> /etc/sysctl.conf
# sudo sysctl -p

# Check rvm and ruby install stuff first since even brew installs via ruby
RUBY_UPDATED="no"
if [ "$(uname)" == "Darwin" ]; then

  echo "Verifying rvm (Ruby Version Manager) installation (want $RVM_VERSION_WANTED)"
  if ! RVM_VERSION=$(rvm --version 2>/dev/null|cut -f2 -d' ') || [ "$RVM_VERSION" != "$RVM_VERSION_WANTED" ]; then
    echo "rvm either not installed or unexpected version. Wanted '$RVM_VERSION_WANTED', got '$RVM_VERSION'"
    if ! gpg --list-key 409B6B1796C275462A1703113804BB82D39DC0E3 > /dev/null 2>&1; then
      echo "Installing the rvm gpg keys then rvm"
      gpg --keyserver hkp://na.pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
    fi
    \curl -sSL https://get.rvm.io | bash -s stable
    # shellcheck disable=SC1090
    source ~/.rvm/scripts/rvm
  fi

  # FIXME, run this for linux too?
  echo "Verifying ruby installation (want $RUBY_VERSION_WANTED)"
  if ! RUBY_VERSION=$(rvm list 2>/dev/null|grep '\=\* ruby'|cut -f'2' -d' ') || [ "$RUBY_VERSION" != "$RUBY_VERSION_WANTED" ]; then
    echo "ruby either not installed or unexpected version. Wanted '$RUBY_VERSION_WANTED', got '$RUBY_VERSION'"
    echo "installing ruby..."
    rvm install $RUBY_VERSION_WANTED
    # shellcheck disable=SC1090
    source ~/.rvm/scripts/rvm
    rvm reload
    rvm --default $RUBY_VERSION_WANTED
    rvm use $RUBY_VERSION_WANTED
    rvm cleanup all
    RUBY_UPDATED="yes"
  fi

  # fastlane version `gem list|grep ^fastlane`
  echo "Verifying fastlane (automated iOS build system) installation (want $FASTLANE_VERSION_WANTED)"
  if ! FASTLANE_VERSION=$(gem list|grep ^fastlane) || [[ "$FASTLANE_VERSION" != *"fastlane ($FASTLANE_VERSION_WANTED"* ]]; then
    echo "fastlane not installed or wrong version. Wanted '$FASTLANE_VERSION_WANTED', got '$FASTLANE_VERSION'"
    echo "If you are going from fastlane 2.151 to 2.152 they messed up their gem dependencies"
    echo "The only way to get around this is to do 'rm ~/.rvm' and re-run doctor"
    echo "installing fastlane..."
    gem install fastlane --version $FASTLANE_VERSION_WANTED
    gem cleanup
  fi

  # rebuild the certificates so doing builds works
  echo "Rebuilding local Xcode certificates and provisioning profiles via fastlane"
  echo "If this your first doctor run, you may need the password from the Usage section in packages/public-app/BUILD_DEPLOY.md"
  pushd packages/public-app || (echo "Unable to change directory to packages/public-app" && exit 1)
  FASTLANE_DISABLE_OUTPUT_FORMAT=FALSE fastlane ios certificates > /dev/null
  popd || (echo "Unable to return to previous directory" && exit 1)

  echo "Verifying cocoapods installation (want $COCOAPODS_VERSION_WANTED)"
  if ! COCOAPODS_VERSION=$(pod --version 2>/dev/null) || [ "$COCOAPODS_VERSION" != "$COCOAPODS_VERSION_WANTED" ]; then
    echo "cocoapods not installed or wrong version. Wanted '$COCOAPODS_VERSION_WANTED', got '$COCOAPODS_VERSION'"
    echo "installing cocoapods..."
    gem install cocoapods --version $COCOAPODS_VERSION_WANTED
    gem cleanup
  fi
fi

# Check java install status
JDK_VERSION="11"
echo "Verifying installed Java Development Kit is openjdk$JDK_VERSION"
if ! JAVA_VERSION=$(java -fullversion 2>&1) || [[ "$JAVA_VERSION" != *"openjdk full version \"11.0.11"* ]]; then
  echo "Java package should be adoptopenjdk$JDK_VERSION but java version was $JAVA_VERSION"

  if [ "$(uname)" == "Darwin" ]; then
    echo "Installing openjdk$JDK_VERSION via brew on macOS"
    brew untap adoptopenjdk/openjdk || true
    brew cleanup
    brew tap AdoptOpenJDK/openjdk
    brew install adoptopenjdk$JDK_VERSION
    # shellcheck disable=SC2129
    echo "# --- Add JAVA_HOME items" >> "$HOME/.bash_profile"
    echo "JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-$JDK_VERSION.jdk/Contents/Home" >> "$HOME/.bash_profile"
    echo "export JAVA_HOME" >> "$HOME/.bash_profile"
    echo "PATH=\$JAVA_HOME/bin:\$PATH" >> "$HOME/.bash_profile"
    echo "export PATH" >> "$HOME/.bash_profile"
    echo "# --- End add JAVA_HOME items" >> "$HOME/.bash_profile"
    echo "!!! You will need to start a new Terminal session for $JDK_VERSION to be in effect."
  else
    echo "You appear to not have openjdk full version $JDK_VERSION installed, but it is required. Cannot proceed"
    exit 1
  fi
fi

# FIXME
# Check python and virtualenv and our python libraries install status - TODO but this is needed for the calculator
# python currently 2.7.16?
# brew cask install anaconda # add this to the profile, and run it now to init
# conda create -n virtualenv python=3.7 #  after doing this fire it up so we are in that environment
# conda activate virtualenv
# pip install wheel pandas sklearn packaging rpy2 tzlocal

# FIXME
# Check R and R library install status - TODO but needed for the calculator

# Check Android Studio status optionally?
echo "Verifying Android SDK installation"
if [ "$ANDROID_SDK_ROOT" == "" ]; then
  echo "ANDROID_SDK_ROOT environment variable not found. Configuring standard location"
  USER=$(whoami)
  if [ "$(uname)" == "Darwin" ]; then
    export ANDROID_SDK_ROOT="/Users/$USER/Library/Android/sdk"
  else
    export ANDROID_SDK_ROOT="/home/$USER/Android/Sdk"
  fi
  if ! [ -d "$ANDROID_SDK_ROOT/" ]; then
    echo "Configuring ANDROID_SDK_ROOT to standard location $ANDROID_SDK_ROOT failed"
    exit 1
  else
    echo "export ANDROID_SDK_ROOT=\"$ANDROID_SDK_ROOT\"" >> "$HOME/.bash_profile"
    echo "export PATH=\"\$ANDROID_SDK_ROOT/emulator:\$ANDROID_SDK_ROOT/platform-tools:\$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:\$ANDROID_SDK_ROOT/tools:\$PATH\"" >> "$HOME/.bash_profile"
    echo "Standard ANDROID_SDK_ROOT location found. Auto-configuration successful."
    echo "!!! You will need to start a new Terminal session before Android builds work."
  fi
fi

# Verify apkanalyzer (used for Android release build script) works after Java11 update
echo "Verifying Android command-line tools are up to date and in PATH"
if ! apkanalyzer > /dev/null 2>&1; then
  echo "Android command-line tools not set up correctly, fixing..."
  if ! [ -f "$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/apkanalyzer" ]; then
    echo "Android development has updated to Java 11, but your command-line tools don't support it."
    echo "You need to open Android Studio, start the SDK Manager tool, install command-line tools, re-run doctor"
    exit 1
  fi
  echo "export PATH=\"\$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:\$PATH\"" >> "$HOME/.bash_profile"
fi

# check Android NDK is installed, if not release APK is bigger because there is no strip tool
ANDROID_NDK_WANTED=$(grep ndkVersion < packages/public-app/android/build.gradle | cut -d"'" -f2)
echo "Verifying Android NDK (want version $ANDROID_NDK_WANTED)"  
if ! ls -1 "$ANDROID_SDK_ROOT/ndk/$ANDROID_NDK_WANTED/package.xml" >/dev/null 2>&1; then
  echo "Android NDK not installed or not correct version (got $ANDROID_NDK). Installing NDK $ANDROID_NDK_WANTED"
  echo 'count=0' > ~/.android/repositories.cfg
  if ! echo y | "$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager" --no_https "ndk;$ANDROID_NDK_WANTED"; then
    echo "Installing Android NDK failed?"
    exit 1
  fi
fi

# On the opposite side, if the android project local.properties has 'ndk.dir' in it, that is
# obsolete and causes problems
ANDROID_PROPS="packages/public-app/android/local.properties"
if grep ndk $ANDROID_PROPS >/dev/null 2>&1; then
  echo "Obsolete 'ndk.dir' property found in public-app Android project. Removing it."
  rm -f $ANDROID_PROPS.new
  grep -v ndk < $ANDROID_PROPS > $ANDROID_PROPS.new
  mv -f $ANDROID_PROPS.new $ANDROID_PROPS
fi

# Check At least that we have one known emulator name
# If we don't have that emulator than we should try to create it? Verify we have the right device/sdk etc?
# Verify haxm is installed?

echo
echo -------------------------------------------------
echo Done verifying installation pre-requisites.
echo -------------------------------------------------
echo

echo
echo -------------------------------------------------
echo Installing top level nodejs modules.
echo -------------------------------------------------
echo
yarn

echo
echo -------------------------------------------------
echo Installing and cross-linking sub-package modules.
echo -------------------------------------------------
echo

# This is needed because we might update patches, and they won't apply cleanly
\rm -fr packages/public-app/node_modules

nvm use $NODE_CURRENT_VERSION # currently everything works on v14, force switch to it to make sure it is in use
npx lerna bootstrap

echo
echo -------------------------------------------------
echo Cleaning previous public-app builds
echo -------------------------------------------------
echo
pushd packages/public-app || (echo "Unable to change directory to packages/public-app" && exit 1)
yarn deep-clean
popd || (echo "Unable to return to previous directory" && exit 1)

if [ "$(uname)" == "Darwin" ]; then
  echo
  echo -------------------------------------------------
  echo Installing cocoapods in sub-package modules.
  echo -------------------------------------------------
  echo
  npx lerna run install-pods
fi

echo
echo -------------------------------------------------
echo Running yarn in API and Admin for SQLite3 install
echo -------------------------------------------------
echo
pushd packages/api || (echo "Unable to change directory to packages/api" && exit 1)
\rm -fr node_modules && yarn
popd || (echo "Unable to return to previous directory" && exit 1)
pushd packages/admin || (echo "Unable to change directory to packages/admin" && exit 1)
\rm -fr node_modules && yarn
popd || (echo "Unable to return to previous directory" && exit 1)

echo
echo -------------------------------------------------
echo Running test script in all sub-package modules.
echo -------------------------------------------------
echo
npx lerna run test

echo
echo ---------------------------------------------------------------
echo Running test android build in public-app to fetch dependencies.
echo ---------------------------------------------------------------
echo
pushd packages/public-app/android || (echo "Unable to change directory to packages/public-app/android" && exit 1)
./gradlew assembleDevDebug
popd || (echo "Unable to return to previous directory" && exit 1)

if [ "$NVM_INSTALL" == "true" ] || [ "$AVM_INSTALL" == "true" ]; then
  echo "You need open a fresh terminal session, or copy and paste this command: "
  echo "source ~/.nvm/nvm.sh && source ~/.nvm/auto-nvm.sh"
fi

if [ "$RUBY_UPDATED" == "yes" ]; then
  echo "Ruby updated. Old versions consume lots of disk space."
  echo "Easiest way to free the disk space is a full delete of ~/.rvm"
  echo "then run doctor.sh again from a new terminal to install only the current version."
fi
morghan102 commented 3 years ago

My environment is configured according to the instructions, so I'm not sure that is the problem.

mikehardy commented 3 years ago

I confirm I just ran make-demo.sh successfully start to finish with iOS and Android both running the app successfully on my macOS machine.

I don't want to go too far off on a tangent debugging some script now on your environment vs the actual module here, as it is really just meant to be a proving ground to verify things.

However, this leaves us in roughly the same state: react-native-firebase works in our CI environments, and in my work projects. Scripts that run and programmatically start from scratch then test-integrate it and test-run it work for me just now, personally verified. But it's not working for you.

The only deduction supported by facts is that something is wrong with your environment or integration. It could be nearly anything - that's why I made the test script to show step by step every step needed, but it's still not working.

I'm not sure what more I can do?

morghan102 commented 3 years ago

No, this is a good jumping off point. Thank you! I'm considering uninstalling Android studio and then reinstalling - is this a god idea or could it cause further mess?

mikehardy commented 3 years ago

OMG I'm laughing out loud but it's not your fault. Normally, my answer to your statement would be "well, it can't hurt" but on this particular day, it's the worst idea. Just as a coincidence, Android Studio just today released version 7 ("Arctic Fox") taking over from it's 4.x series (4.2.2 was previous stable version) and it is a major release, with breaking changes all up and down the Android toolchain. So it would be like installing Xcode 13 right now on the morning of it's release - just asking for trouble.

So today specifically I have to say I would not encourage it unless you downloaded the old stable version 4.2.2.

This must be a frustrating experience, wish it were something obvious

mikehardy commented 3 years ago

(I literally have a stack of about 10 dependabot dependency update pull requests that all broke builds, because of the new android studio release, and I only took a break from looking at them in order to check new notifications here :sweat_smile: - good times)

morghan102 commented 3 years ago

Oh my god 😭 Thanks anyways! I think I will try downloading 4.2.2

icarojobs commented 2 years ago

Hi there!

I have the same problem. My environment: › Expo SDK: 45.0.0 › Release channel: default › Workflow: Bare

Windows 11

The error show when I try get device token to work with FCM. Follow the code: invertase-error-2

The error: invertase-error

I'm using the rnfirebase.io steps. Could you help me?

udayaprakashjayaraman commented 9 months ago

@icarojobs is this got resolved? if yes please share me your solution..

icarojobs commented 9 months ago

@icarojobs is this got resolved? if yes please share me your solution..

I solved using the native Google Firebase library.