'Firebase error. Please ensure that you spelled the name of your Firebase correctly
When I try to save value to database, i am getting below error:
Firebase error. Please ensure that you spelled the name of your Firebase correctly
Anybody know how to fix it?
Below is my app's 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'
}
Below is my fragment, I am trying to save text("Hello world") in database onCreateView
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"
}
Error:
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
Solution 1:[1]
Thanks every one for contributing. it was my first time working on firebase android project with java and was getting that error. After adding the data, download the google_services.json again and copy to app folder. Then add the following dependencies in app build.gradle
implementation platform('com.google.firebase:firebase-bom:29.0.1')
implementation 'com.google.firebase:firebase-analytics
Solution 2:[2]
that is my firebase database url which was generated automatically in the google_services.json after adding data
"firebase_url": "https://fir-dec-cc5ce-default-rtdb.firebaseio.com/"
Solution 3:[3]
Check if you have added SHA-1 in project settings in Firebase or not.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | SENIOR ICT CONSULTANT |
| Solution 2 | SENIOR ICT CONSULTANT |
| Solution 3 | Mayura Devani |
