gpt4 book ai didi

android - 火力地堡错误。请确保您正确拼写了 Firebase 的名称

转载 作者:行者123 更新时间:2023-12-05 00:03:52 25 4
gpt4 key购买 nike

当我尝试将值保存到数据库时,出现以下错误:

Firebase error. Please ensure that you spelled the name of your Firebase correctly

有人知道怎么解决吗?

下面是我的app的build.gradle

build.gradle

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'

android {
compileSdkVersion 30

defaultConfig {
applicationId "com.android.armessage"
minSdkVersion 24
targetSdkVersion 30
versionCode 1
versionName "1.0"
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}

dependencies {
implementation "org.koin:koin-android-viewmodel:$koin_version"
implementation 'com.google.firebase:firebase-database-ktx:19.6.0'
}

下面是我的 fragment ,我试图在数据库 onCreateView 中保存文本(“Hello world”)


class BottomSheetFragment: BottomSheetDialogFragment() {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val inflate = inflater.inflate(R.layout.bottom_sheet, container, false)

val database = FirebaseDatabase.getInstance()
database?.setLogLevel(Logger.Level.DEBUG)
val myRef = database!!.reference
myRef.setValue("Hello, World!")

return view
}
}

google-services.json

{
"project_info": {
"project_number": "1262330",
"firebase_url": "https://rt-73b76-default-rtdb.europe-west1.firebasedatabase.app",
"project_id": "rtb76",
"storage_bucket": "rtb76.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:4545:f33",
"android_client_info": {
"package_name": "com.android.demo"
}
},
"oauth_client": [
{
"client_id": "555677-77.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "44545-45455"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "454545-54545.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
}
],
"configuration_version": "1"
}

错误:

websocket opened
2020-12-26 23:50:37.012 3867-4287/com.android.demo D/WebSocket: ws_0 - Reset keepAlive
2020-12-26 23:50:37.014 3867-4288/com.android.demo D/WebSocket: ws_0 - ws message: {"t":"c","d":{"t":"s","d":"Firebase error. Please ensure that you spelled the name of your Firebase correctly"}}
2020-12-26 23:50:37.014 3867-4287/com.android.demo D/WebSocket: ws_0 - Reset keepAlive. Remaining: 44998
2020-12-26 23:50:37.015 3867-4287/com.android.demo D/WebSocket: ws_0 - HandleNewFrameCount: 1
2020-12-26 23:50:37.015 3867-4287/com.android.demo D/WebSocket: ws_0 - handleIncomingFrame complete frame: {t=c, d={t=s, d=Firebase error. Please ensure that you spelled the name of your Firebase correctly}}
2020-12-26 23:50:37.016 3867-4287/com.android.demo D/Connection: conn_0 - Got control message: {t=s, d=Firebase error. Please ensure that you spelled the name of your Firebase correctly}
2020-12-26 23:50:37.016 3867-4287/com.android.demo D/Connection: conn_0 - Connection shutdown command received. Shutting down...
2020-12-26 23:50:37.016 3867-4287/com.android.demo D/PersistentConnection: pc_0 - Firebase Database connection was forcefully killed by the server. Will not attempt reconnect. Reason: Firebase error. Please ensure that you spelled the name of your Firebase correctly
2020-12-26 23:50:37.016 3867-4287/com.android.demo D/PersistentConnection: pc_0 - Connection interrupted for: server_kill
2020-12-26 23:50:37.016 3867-4287/com.android.demo D/Connection: conn_0 - closing realtime connection
2020-12-26 23:50:37.016 3867-4287/com.android.demo D/WebSocket: ws_0 - websocket is being closed

最佳答案

在我的例子中,这是因为我使用的是 RTDB 的 europe-west1 beta 区域。指定 databaseURL(您可以在 Firebase RTDB 控制台中找到它)修复它:

const firebaseConfig = {
apiKey: "####",
// ...
databaseURL: "https://xxx-default-rtdb.europe-west1.firebasedatabase.app/",
};

关于android - 火力地堡错误。请确保您正确拼写了 Firebase 的名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65461477/

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