How to Sync Project with Gradle Files when Adding Firebase to Flutter Android App in Android Studio (April 2020)

3,919

Solution 1

According to your picture, it looks like you are using flutter and not native android development. If you want to add firebase analytics to your flutter app then you need to go to the pubspec.yaml file, and you can add the dependency:

dependencies:
  firebase_analytics: ^5.0.11

After adding it a top bar will appear to that will automatically execute pub get

https://pub.dev/packages/firebase_analytics#-installing-tab-

Solution 2

what I do is open the android folder of our Flutter project as a new project,

** Archivo> Abrir> Proyect-android **

in this way the IDE recognizes it, and enables the Gradle synchronization button ( only enabled in native android projects)

Image Example

once synced, you can close the native Android project, and it would be synced to your Flutter project

Share:
3,919
Derence
Author by

Derence

Updated on November 21, 2022

Comments

  • Derence
    Derence over 1 year

    Edit: This question refers to Flutter apps.

    When adding Firebase to my Android app, the instructions say: "Finally, press "Sync now" in the bar that appears in the IDE"

    enter image description here

    However, no bar appears in Android Studio.

    It seems that there used to be a button in the tool bar: Where is a "Sync project with gradle files" button in Android Studio 3?

    And that more recently it could be found at "File > Sync Project with Gradle Files": Syncing Android Studio project with Gradle files

    But neither of those options exist in Android Studio as of April 4, 2020. The closest thing I can find is an item in the dropdown menu that says "Sync with File System."

    enter image description here

    I thought maybe it was the same thing, but they are not: What is the difference between Sync project with gradle files and Sync with File System?

    Any ideas how I can sync project with gradle files in Android Studio in April 2020?

    Thank you!

  • Derence
    Derence about 4 years
    Thanks for your answer! Yes, it is in Flutter. Just a moment before you answered I tried this: stackoverflow.com/a/60260032/10336149 and it seems to have worked. After I clicked next and ran my app, it said something like "Congrats! Your app in now connected to Firebase." I assume I will also need to add the firebase_analytics: ^5.0.11 package to the pubspec.yaml file, but for future reference, is adding the package all that needs to be done? In other words, is that entire process in the Firebase console (firebase.google.com/docs/android/setup#console) unnecessary?
  • Peter Haddad
    Peter Haddad about 4 years
    You should follow this firebase.google.com/docs/flutter/setup when cresting a flutter project with firebase. The google-services.json and adding the google-services in build.gradle are necessary, and yes you also need to add the plugins, if lets say you want to use firestore then you have to add the cloud firestore plugin also
  • blimpse
    blimpse over 3 years
    I'm using React Native, and this is what I needed to do. Thanks!