亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Firestore 憑據問題:Firebase 應用 [默認] 已存在

Firestore 憑據問題:Firebase 應用 [默認] 已存在

Cats萌萌 2023-06-14 14:29:18
我正在用 JavaFX 構建一個簡單的程序,用于將 .xls 文件上傳到我的 firebase/firestore 項目。每次我嘗試運行該程序并單擊一個按鈕來初始化我的上傳器類時,它都會失敗并顯示一條錯誤消息:FirebaseApp 名稱 [DEFAULT] 已經存在!找了半天,還是沒找到有用的。我已經嘗試過 OAuth2 令牌(在 Google Cloud 中創建了一個服務帳戶,獲得了 JSON 文件)、環境變量(不會檢測到),以及文檔中的幾乎所有內容。  FileInputStream serviceAccount = new FileInputStream("<path>.json");FirebaseOptions options = new FirebaseOptions.Builder()        .setCredentials(GoogleCredentials.fromStream(serviceAccount))        .setDatabaseUrl("https://<project>.firebaseio.com/")        .build();    FirebaseApp.initializeApp(options); <----This line won't compile for some reason..Firebase app =FirebaseApp.initializeApp(options); <--------- This will compile我正在使用 Gradle 作為我的構建工具。這是我到目前為止所得到的,它似乎可以很好地構建而沒有問題。我是否缺少任何依賴項? plugins {    id 'java'    id 'org.openjfx.javafxplugin' version '0.0.8'    id 'application'}version '1.0-SNAPSHOT'sourceCompatibility = 1.8repositories {    mavenCentral()    jcenter()    google()}dependencies {    testCompile group: 'junit', name: 'junit', version: '4.12'    compile "org.apache.poi:poi:3.17"    compile "org.apache.poi:poi-ooxml:3.17"    implementation 'com.google.firebase:firebase-auth:18.1.0'    implementation 'com.google.firebase:firebase-admin:6.9.0'    implementation 'com.google.firebase:firebase-firestore:20.2.0'    compile 'com.google.firebase:firebase-admin:6.9.0'}javafx {    version = '12'    modules = ['javafx.controls', 'javafx.fxml']}mainClassName = 'app.Main'apply plugin: 'org.openjfx.javafxplugin'
查看完整描述

1 回答

?
慕妹3242003

TA貢獻1824條經驗 獲得超6個贊

您不能firebase-admin與其他 Firebase Android 庫一起使用,例如firebase-authfirebase-firestore。您應該使用 Admin SDK 或 Android SDK,但絕不能同時使用兩者。

來到確切的錯誤消息,這表明initializeApp()在您的應用程序中被多次調用。它正在嘗試初始化[DEFAULT], 當一個已經存在時。


查看完整回答
反對 回復 2023-06-14
  • 1 回答
  • 0 關注
  • 156 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號