16

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?

Stiño
  • 2,663
  • 7
  • 25
  • 47

6 Answers6

18

Just download the newest JDK version from here

Austris Cirulnieks
  • 1,099
  • 11
  • 18
9

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
adius
  • 13,685
  • 7
  • 45
  • 46
7

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.

  • Thanks! This told me that firebase couldn't find Java Runtime on my system: `The operation couldn’t be completed. Unable to locate a Java Runtime.` – Ajay Maity May 10 '21 at 10:16
4

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).

atereshkov
  • 4,311
  • 1
  • 38
  • 49
  • Hello I have installed the latest version of Java but I am still getting the code 1 bug. What am I missing here? – Morpheus Apr 13 '21 at 16:32
4

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

Itay Tur
  • 683
  • 1
  • 15
  • 40
1

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.

Bennysce
  • 43
  • 7