Search code examples
javagoogle-app-enginefirebasegoogle-cloud-endpointsfirebase-admin

NoSuchMethod error on Google App Engine


My Google App Engine server runs:

  • The Firebase Admin SDK
  • Google Cloud Endpoints v2

After updating to Endpoints v2 recently (unsure if related), I have been getting this error on the server while my mobile app:

com.google.api.server.spi.SystemService invokeServiceMethod: exception occurred while calling backend method
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)
at com.google.firebase.FirebaseApp.getOptions(FirebaseApp.java:260)
at com.google.firebase.auth.FirebaseAuth.<init>(FirebaseAuth.java:74)
at com.google.firebase.auth.FirebaseAuth.<init>(FirebaseAuth.java:61)
at com.google.firebase.auth.FirebaseAuth.<init>(FirebaseAuth.java:52)
at com.google.firebase.auth.FirebaseAuth$FirebaseAuthService.<init>(FirebaseAuth.java:316)
at com.google.firebase.auth.FirebaseAuth.getInstance(FirebaseAuth.java:98)
at com.google.firebase.auth.FirebaseAuth.getInstance(FirebaseAuth.java:85)
at com.project.apis.UserAPI.verifyUserIDToken(MyAPI.java:100)

Can anyone advise? Other reports have suggested updating the Guava dependency in my pom.xml, but I am not even using Guava:


Solution

  • This happens when there are 2 incompatible versions of guava in the classpath. Firebase uses one version (v20.0), and the Google App Engine libraries use an older version (v18.0 I believe). You can check the dependency tree using the mvn dependency:tree command, and then add an exclusion rule to the older version.