Firebase Cloud Functions emulator throws "exited with code: 1" error - firebase

I'm trying to setup my local environment for testing firebase cloud functions. I've followed along with their documentation but now bump into the following error:
Error: firestore: emulator has exited with code: 1
I've found other SO threads regarding this issue but none with my specific logs:
i Starting emulators: ["functions","firestore","hosting"]
⚠ Your requested "node" version "8" doesn't match your global version "12"
✔ functions: Emulator started at http://localhost:5001
i firestore: Logging to firestore-debug.log
✔ firestore: Emulator started at http://localhost:8080
Error: firestore: emulator has exited with code: 1
The firestore-debug.log file does not really hint me in a direction neither:
Exception in thread "main" java.lang.UnsupportedClassVersionError: com/google/cloud/datastore/emulator/firestore/CloudFirestore : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:637)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Anyone here an idea what's causing this bug?

Just download the newest JDK version from here

On macOS 10.14 I needed to install the latest openjdk and enable it:
brew install openjdk
During installation it will then display instructions on how to enable the openjdk. For me it was:
For the system Java wrappers to find this JDK, symlink it with
sudo ln -sfn \
/usr/local/opt/openjdk/libexec/openjdk.jdk \
/Library/Java/JavaVirtualMachines/openjdk.jdk

In case anyone still struggles with this:
Run your emulators:start command again with --debug at the end to see why the process is crashing, right in the terminal.

To check whether you have installed JDK run:
javac -version
If no JDK found, so download it from here:
https://www.oracle.com/java/technologies/javase-downloads.html
(always latest version).

In addition of downloading JDK, I also needed to restart the computer.

It is more convenient to use AdoptOpenJDK installer for Windows to get the environment setup automatically.
How to install OpenJDK 11 on Windows?
https://adoptopenjdk.net/
You will still need to refresh your cmd or powershell to get access to the new environment variables PATH and JAVA_HOME the installer setup.

Related

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0 in android studio

I am trying to run my emulator after adding the firebase and google sign in plug ins/dependencies to my gradle.build files and now I am receiving the error
"Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0"
anyone know if I am doing something wrong this is a react native firebase app.
I am not sure what to try. This is my first app I am doing for a project at school and I do not really know what I am doing. I have just been following tutorials online
Solve this issue by deleting the .gradle folder from <NameOfProject>/android and again run npm run android
I think I just had this same problem. I don't have any idea what your error logs are though so I am not certain however this is my error log right here:
`> Task :react-native-gradle-plugin:compileKotlin FAILED
'compileJava' task (current target is 1.8) and 'compileKotlin' task (current target is 11) jvm targeta version. 1 actionable task: 1 executed`
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':react-native-gradle-plugin:compileKotlin'. Failed to query the value of task ':react-native-gradle-plugin:compileKotlin' property 'compilerRun Kotlin could not find the required JDK tools in the Java installation. Make sure Kotlin compilat
This error however I fixed by editing the gradle-wrapper.properties file's distributionUrl variable. I changed the distributionUrls gradle version to 7.4.2 the file is in Project-Name\android\gradle\wrapper\gradle-wrapper.properties
My error log is saying that gradle's version of JVM want's to be version 11 and is not but you can check gradle's jvm version by using cd android in the project root directory and after that run ./gradlew --version Change JVM's version from the version it is showing to the version that it says is required like in my case v 11. The way I changed gradle's JVM version required chocolatey which is a package manager. This is where you can require it https://chocolatey.org/install and after you have setup chocolatey open a new terminal that has administrative privileges and run this choco install -y nodejs-lts openjdk11 with the JVM version it is asking for inside your error logs
and finally run npm start and after that npm run android inside a refreshed and new terminal and gradle's JVM version and gradle's version will be updated to the specified versions
We could better help if you could you show us your android/build.gradle and android/app/build.gradle files, but here are more specific instructions than you find in the docs:
In android/build.gradle, dependencies should look something like this:
dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'com.google.gms:google-services:4.3.10'
classpath("com.android.tools.build:gradle:<version>")
classpath("com.facebook.react:react-native-gradle-plugin")
classpath("de.undercouch:gradle-download-task:<version>")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
see: https://github.com/gyani-sunkara/rn-firebase-login-starter/blob/main/android/build.gradle
It is known this works with the classpaths at the beginning.
--
Also in android/app/build.gradle, it is known that the google-services dep works at the end of the file.
apply plugin: 'com.google.gms.google-services'
and make this the last "implementation" under dependencies (around line 272)
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.0.0' // <-- add this; newer versions should work too
see: https://github.com/gyani-sunkara/rn-firebase-login-starter/blob/main/android/app/build.gradle
Then, delete android/.gradle and run npx react-native run-android in the root directory.

flutterfire : The term 'flutterfire' is not recognized as the name of a cmdlet, function, script file, or operable program

I am getting this error when I run "dart pub global activate flutterfire_cli" :
Activated flutterfire_cli 0.1.1+2. Package flutterfire_cli is
currently active at version 0.1.1+2. Resolving dependencies... The
package flutterfire_cli is already activated at newest available
version. To recompile executables, first-run dart pub global deactivate flutterfire_cli. Installed executable flutterfire.
Warning: Pub installs executables into
C:\Users\PC\AppData\Local\Pub\Cache\bin, which is not on your path.
You can fix that by adding that directory to your system's "Path"
environment variable. A web search for "configure windows path" will
show you how
I have added this to my user path but I am still getting this error.
I checked for solutionsto similar problems which suggested I restart the windows or vs code or terminal - I did all three but it is still not working .
I ran in cmd in that it did not give the warning but when I ran flutterfire configure . It gave this error:
"FirebaseCommandException: An error occured on the Firebase CLI when
attempting to run a command. COMMAND: firebase --version ERROR: The
FlutterFire CLI currently requires the official Firebase CLI to also
be installed, see
https://firebase.google.com/docs/cli#install_the_firebase_cli for how
to install it."
running firebase --version gave this error:
'firebase' is not recognized as an internal or external command,
operable program or batch file
This should not be happening as I did connect my app to firebase console.
What worked for me is instead of typing
flutterfire I use flutterfire.bat, e.g. flutterfire.bat configure, that way the command works in the git bash with windows.
You have to add Flutter SDK path to your system environment. The error is arising because your system is not able to find the folder where you have installed Flutter in your system.
You may refer to the Stackoverflow case for the steps on how to set path for the system environment.
Alternatively, you may also refer to the video link.
If you have windows 10. Do not use firebase-tools-instant-win.exe its a trap!
Add Paths to System Variables. Don't forget to change to your username in YOU-USER-NAME
C:\Users\YOU-USER-NAME\AppData\Local\Pub\Cache\bin
C:\Users\YOU-USER-NAME\AppData\Roaming\npm
Next you can execute anywhere (in cmd or firebase-tools-instant-win.exe)
firebase login
npm install -g firebase-tools
dart pub global activate flutterfire_cli
Next you open only cmd.exe command promt and go to the root of your project.
cd c:\PATH-TO-YOU-PROJECT
flutterfire configure

Deploy a SSR Nuxt 2 application on firebase

I have some troubles deploying a Nuxt 2.4 application on Firebase.
I tried these 2 tutorials but they seem outdated:
https://www.youtube.com/watch?v=ZYUWsjUxxUQ
https://github.com/davidroyer/nuxt2-ssr-firebase
With the first tutorial, I could make my app working on local (after few hours and with a lot of modifications for babel integration) but I never could serve or deploy it. I thought the tutorial was old and manipulations can't be exactly done like the guy did.
With the second tutorial, I cloned the repository to try to deploy the example. I had to change 2 things : install Node 8 instead of Node 10 and upgrading firebase-admin to the last version in prod/server dir. Here is what I got:
npm run setup is ok
npm run dev is ok and the project works fine
npm run build is ok
npm run serve fails.
First I got this error :
The Cloud Functions emulator requires the module "firebase-admin" to be version >7.0.0 so your version is too old. You can probably fix this by running "npm install firebase-admin#latest" in your functions directory.
Indeed, the version configured in package.json is the 5.13. I did the update from the prod/server dir, and I get the 8.0.0.
And then I got a different error about gRPC :
Error: Failed to load gRPC binary module because it was not installed for the current system
Expected directory: node-v57-darwin-x64-unknown
Found: [node-v64-darwin-x64-unknown]
This problem can often be fixed by running "npm rebuild" on the current system
I tried npm rebuild as mentionned, without success.
npm run deploy fails.
I get this trace:
i deploying functions, hosting
i functions: ensuring necessary APIs are enabled...
✔ functions: all necessary APIs are enabled
i functions: preparing prod/server directory for uploading...
Error: Error parsing triggers: Cannot find module 'acorn'
Try running "npm install" in your functions directory before deploying.
Of course, I tried the npm install from prod/server dir, but nothing changed.
Is there somewhere i can find a tutorial that can help me deploy my SSR app to firebase ? Thanks in avdance !
EDIT 1 :
After a few modifications on my package.json
upgrading firebase-functions and express to the latest versions
downgrading firebase-admin to the 7.0.0 version
adding acorn
I can serve and deploy but I get a "504 gateway time-out" webpage when I call the URL....
Have you tried to run npm install grpc inside functions folder?

Can't check Meteor Version in Terminal

[react-pocketscholar (master)]$ meteor --version
/Users/ftrflyr/.meteor/packages/meteor-tool/.1.3.4_3.1v4v008++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/meteor-promise/promise_server.js:165
throw error;
^
Error: EEXIST, symlink '/Users/ftrflyr/.meteor/packages/meteor-tool/.1.3.4_3.1v4v008++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle'
[react-pocketscholar (master)]$ meteor -v
/Users/ftrflyr/.meteor/packages/meteor-tool/.1.3.4_3.1v4v008++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/meteor-promise/promise_server.js:165
throw error;
^
Error: EEXIST, symlink '/Users/ftrflyr/.meteor/packages/meteor-tool/.1.3.4_3.1v4v008++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle'
1. Global tool version of meteor command
Find version by:
meteor --version
2. Project version of meteor
A project stays at the meteor version which it was created with unless manually upgraded. Find this by running:
cat .meteor/release
Another way to do this is to open up your Javascript console in the browser and type:
console.log(Meteor);
This is very useful for me as I'm running Ubuntu on a Chromebook so I don't need to stop my local server to check which version I'm currently running.
Please note the server does need to be running (localhost:3000) for this command to work.
You have to be in a meteor project repository and type meteor --version

Memcachier add-on for cloudcontrol is failing

I followed the installation guide at https://www.cloudcontrol.com/dev-center/Add-on%20Documentation/Data%20Storage/MemCachier. The memcachier server is up and running, I tested it from the command line. But my cloudcontrol app isn't able to access it.
Here's the error in our logs:
Info MemcachedError: error 40 from memcached_set: FAILED TO SEND AUTHENTICATION TO SERVER, no mechanism available, host: [my-memcachier-server-url]:11211 -> libmemcached/sasl.cc:221
Notice No worthy mechs found
This seems to be a SASL-related issue. Is it possible that cctrl does not have the correct sasl2 libraries installed? Did anyone else experience this problem?
Further info:
django-pylibmc==0.5.0 and pylibmc==1.4.1 in requirements.txt
url and credentials are read from the cctrl environment correctly
This is caused by the libmemched version bundled with the buildpack missing a patch (https://bugs.launchpad.net/libmemcached/+bug/1381160). Because it is a stackoverflow bug, it can work systematically on your machine while it systematically breaks in the container. I will update the python buildpack to use the patched libmemcached library from the stack.
In the meantime you can try to achieve this manually by setting the LD_LIBRARY_PATH environment variable to /usr/local/lib either via config add-on or web: env LD_LIBRARY_PATH=/usr/local/lib <your_command> in the Procfile.

Resources