// ...
classpath 'com.android.tools.build:gradle:7.2.1' // or the latest version
}```
n your app-level build.gradle (usually located in android/app/build.gradle), add the following at the bottom of the file:
```apply plugin: 'com.google.gms.google-services'```
then after make these changes
run ```flutter pub get ```
and Double-check your dependencies in the `pubspec.yaml `
```dependencies:
firebase_core: ^latest_version
firebase_auth: ^latest_version
firebase_database: ^latest_version
firebase_messaging: ^latest_version```
3.Check google-services.json:
Ensure that the google-services.json file in your android/app directory is correctly configured for your Firebase project.
4.Clean and Rebuild:
Sometimes, issues can be resolved by cleaning and rebuilding the project. In Android Studio, you can find these options in the "Build" menu.
1条答案
按热度按时间kzmpq1sx1#
1.将Firebase添加到Flutter项目:确保您已通过以下步骤将Firebase添加到Flutter项目中:打开Firebase控制台(https://console.firebase.google.com/)。创建新项目或选择现有项目。通过点击“添加应用程序”并选择适当的平台(Android)将您的应用程序添加到Firebase项目。按照安装说明进行操作,其中包括下载google-services.json文件。将此文件放在Flutter项目的android/app目录中。
2.配置build.gradle文件:更新Flutter项目中的build.gradle文件,如下所示:
在您的项目级build.gradle(通常位于android/build.gradle中)中,确保您拥有Google Services类路径: