簡體   English   中英

Flutter Firebase 沒有正確初始化。 您是否已將“google-services.json”文件添加到項目中?

[英]Flutter Firebase has not been correctly initialized. Have you added the "google-services.json" file to the project?

我無法在我的 Flutter 應用程序上初始化 Firebase。 我已完成所有步驟

下面是 build.gradle 文件:

  dependencies {
        classpath 'com.android.tools.build:gradle:4.1.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.8'
        
    }

這也是我的 app/build.gradle:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'com.google.gms.google-services'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

google-services.json 位於正確的位置,請參見圖片:

文件結構截圖

我已經多次運行 flutter clean

更新:

像這樣初始化 Firebas:

在此處輸入圖像描述

主要的 function 應該是

void main()async
{
Firebase.initializeApp();
runApp(MyApp());
}

你應該導入 firebase_core 插件

import 'package:firebase_core/firebase_core.dart';

我已經弄清楚了這個問題。 我使用的是 flutter 插件 flutter_multiple_image_picker,它要求我使用 xmlns:tools="http://schemas.android.com/tools",以及 AndroidManifest.xml 中的 tools:node="replace"。 這一定是以某種方式覆蓋了導致此問題的清單中的內容。

這個故事的寓意是不要在你的 AndroidManifest.xml 中使用這個工具模式,因為它會導致一些奇怪的 Android 錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM