user6587056
user6587056

Reputation:

Firebase Admin SDK throws NoSuchMethodError while executing .jar file

When I execute my app with basic Firebase setup as shown below

FileInputStream serviceAccount = new FileInputStream("path/to/serviceAccountKey.json");

FirebaseOptions options = new FirebaseOptions.Builder()
  .setCredential(FirebaseCredentials.fromCertificate(serviceAccount))
  .setDatabaseUrl("https://<DATABASE_NAME>.firebaseio.com/")
  .build();

FirebaseApp.initializeApp(options);
FirebaseDatabase db = FirebaseDatabase.getInstance() // error

I get the following error

Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;)V
    at com.google.firebase.FirebaseApp.checkNotDeleted(FirebaseApp.java:314)

I saw that this might happen because of the low guava version, but the thing is, I'm not using it as a direct dependency (only through Firebase).

Upvotes: 2

Views: 355

Answers (1)

user6587056
user6587056

Reputation:

The problem was in my code, not Firebase SDK. I was trying to load config json file from my resources folder and when I moved it to the project root directory as shown in this demo, it started working.

Upvotes: 1

Related Questions