Home > front end >  how to fix app crashes after implementing firestore?
how to fix app crashes after implementing firestore?

Time:02-11

I'm trying to work with Cloud Firebase-Firestore in my app. I've been following their tutorial (My Implementation:

CodePudding user response:

If you think the implementation may be the issue then instead of using the Firebase BOM try implementing them separately like so:

implementation 'com.google.firebase:firebase-analytics:20.0.2'
implementation 'com.google.firebase:firebase-firestore:24.0.1'

CodePudding user response:

Without more debugging details it would be hard for anyone to pinpoint the exact cause of the issue. Did you receive no traceback logs when running with an Android emulator? Also what led you to say the issue originates from the implementation statements?

Nonetheless, I followed the same guide to add Firebase to a test Android app and ran into some errors (which were resolved), so I post this answer in case one of them is useful.

There is no need to have the allProjects{} block anymore inside the project-level build.gradle file. Based on this related thread, these repositories are now located inside the settings.gradle file:

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        // Other repositories
    }
}

Plugins are also added differently as what is shown in the guide. Instead of using apply plugin statements, the plugin should be included inside the plugins block inside the app-level build.gradle:

plugins {
    id 'com.android.application'
    id 'com.google.gms.google-services'
}

Finally, another error I ran into was a mismatch between my project package name and the package name targeted by google-services.json. This error did not show up when building the app, only when running it with the Android emulator. Make sure they both match.

  • Related