gpt4 book ai didi

Java Firebase-Admin 缺少 GoogleCredentials

转载 作者:太空宇宙 更新时间:2023-11-04 10:41:01 26 4
gpt4 key购买 nike

我想创建一个可以访问我的 Firebase 数据库的服务器应用程序。

我遵循了本指南:https://firebase.google.com/docs/admin/setup#initialize_the_sdk

但我收到以下错误:

cannot resolve GoogleCredentials

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

FirebaseOptions options = new FirebaseOptions.Builder()
.setCredentials(GoogleCredentials.fromStream(serviceAccount))
.setDatabaseUrl("https://<DATABASE_NAME>.firebaseio.com/")
.build();

FirebaseApp.initializeApp(options);

编辑:

导入以下库后:

  • org.json.jar
  • netty-all-4.0.0.final.jar
  • google-http-client-1.16.0-rc.jar
  • google-http-client-1.16.0-rc-sources.jar
  • firebase-admin-5.9.0.jar
  • google-auth-library-oauth2-http-0.9.0.jar
  • google-auth-library-credentials-0.9.0.jar
  • google-api-client-1.23.0.jar
  • google-api-client-1.4.1-beta.jar
  • guava-24.0-jre.jar
  • google-http-client-jackson2-1.23.0.jar
  • jackson-core-2.9.4.jar
  • slf4j-api-1.7.25.jar
  • slf4j-jdk14-1.7.25.jar
  • api-common-1.3.9.jar

我陷入了这个错误:

Feb 27, 2018 2:15:33 PM com.google.firebase.database.logging.LogWrapper error SCHWERWIEGEND: Uncaught exception in Firebase Database runloop (5.9.0). Please report to firebase-database-client@google.com java.lang.NoSuchMethodError: io.netty.channel.nio.NioEventLoopGroup.(ILjava/util/concurrent/Executor;)V at com.google.firebase.database.connection.NettyWebSocketClient.(NettyWebSocketClient.java:71) at com.google.firebase.database.connection.WebsocketConnection$DefaultWSClientFactory.newClient(WebsocketConnection.java:435) at com.google.firebase.database.connection.WebsocketConnection.(WebsocketConnection.java:80) at com.google.firebase.database.connection.WebsocketConnection.(WebsocketConnection.java:68) at com.google.firebase.database.connection.Connection$DefaultWebsocketConnectionFactory.newConnection(Connection.java:297) at com.google.firebase.database.connection.Connection.(Connection.java:72) at com.google.firebase.database.connection.Connection.(Connection.java:57) at com.google.firebase.database.connection.PersistentConnectionImpl$DefaultConnectionFactory.newConnection(PersistentConnectionImpl.java:1303) at com.google.firebase.database.connection.PersistentConnectionImpl.openNetworkConnection(PersistentConnectionImpl.java:547) at com.google.firebase.database.connection.PersistentConnectionImpl.access$800(PersistentConnectionImpl.java:37) at com.google.firebase.database.connection.PersistentConnectionImpl$1$1.onSuccess(PersistentConnectionImpl.java:500) at com.google.firebase.database.core.Context$1$1.onSuccess(Context.java:67) at com.google.firebase.database.core.JvmAuthTokenProvider.getToken(JvmAuthTokenProvider.java:66) at com.google.firebase.database.core.Context$1.getToken(Context.java:62) at com.google.firebase.database.connection.PersistentConnectionImpl$1.run(PersistentConnectionImpl.java:490) at com.google.firebase.database.connection.util.RetryHelper$1.run(RetryHelper.java:93) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)

最佳答案

您需要 Netty 4.1.x。我建议依赖 4.1.17.Final,这是 Admin SDK 所依赖的。您的依赖管理工具(Maven、Gradle 等)应该为您处理这个问题。

关于Java Firebase-Admin 缺少 GoogleCredentials,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48987670/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com