Firebase尚未正确初始化.您是否添加了"google-services.json"归档到项目 [英] Firebase has not been correctly initialized. Have you added the "google-services.json" file to the project

查看:142
本文介绍了Firebase尚未正确初始化.您是否添加了"google-services.json"归档到项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行我的应用程序时出现此错误.我将google-services.json下载到了我的android/app文件夹中.我已经输入了

I'm getting this error when i run my app. I downloaded the google-services.json into my android/app folder. I have put in the

应用插件:"com.google.gms.google-services"

apply plugin: 'com.google.gms.google-services'

进入我的app/build.gradle文件.最初,我没有将应用插件"所以我把它放在后面,似乎没有什么不同.我也把我的

into my app/build.gradle file. Originally i had not put in the "apply plugin" so i put it in later and it doesn't seem to have made a difference. I also put my

classpath'com.google.gms:google-services:4.3.5'

classpath 'com.google.gms:google-services:4.3.5'

into my android/build.gradle. The entire error when i run the app is



E/flutter ( 4213): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: 
[core/not-initialized] Firebase has not been correctly initialized. 
Have you added the 
"google-services.json" file to the project? 
E/flutter ( 4213):     
E/flutter ( 4213): View the Android Installation documentation for more information: 
https://firebase.flutter.dev/docs/installation/android
E/flutter ( 4213): 
E/flutter ( 4213): #0      MethodChannelFirebase.initializeApp 
(package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:88:9)
E/flutter ( 4213): <asynchronous suspension>

E/flutter ( 4213): #1      Firebase.initializeApp (package:firebase_core/src/firebase.dart:41:31)

E/flutter ( 4213): <asynchronous suspension>

E/flutter ( 4213): #2     
 main (package:rider_app/main.dart:12:3)
E/flutter ( 4213): <asynchronous suspension>
E/flutter ( 4213): 

(我看到我可能没有看到的错误还有更多,我希望你们能理解它们)

(edit: i see there's more to the errors that i might not have seen , i'm hoping you guys will make sense of them)

Launching lib\main.dart on Android SDK built for x86 in debug mode...

Running Gradle task 'assembleDebug'...

Note: "path"\flutter_windows_2.0.4-stable\.pub-cache\hosted\pub.dartlang.org
\firebase_core-1.0.3\android\src\main\java\io\flutter\plugins\firebase
\core\FlutterFirebaseCorePlugin.java uses or overrides a deprecated API.

Note: Recompile with -Xlint:deprecation for details.

Note: "path"\flutter_windows_2.0.4-stable\.pub-cache\hosted\pub.dartlang.org
\firebase_auth-1.0.2\android\src\main\java\io\flutter\plugins\firebase
\auth\FlutterFirebaseAuthPlugin.java uses or overrides a deprecated API.

Note: Recompile with -Xlint:deprecation for details.

Note: Some input files use or override a deprecated API.

Note: Recompile with -Xlint:deprecation for details.

√ Built build\app\outputs\flutter-apk\app-debug.apk.

Installing build\app\outputs\flutter-apk\app.apk...

Debug service listening on ws://127.0.0.1:55393/AAigea5LZbA=/ws

Syncing files to device Android SDK built for x86...

D/EGL_emulation( 8043): eglMakeCurrent: 0x9c861020: ver 2 0 (tinfo 
0xaa003f90)

E/flutter ( 8043): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled 
Exception: [core/not-initialized] Firebase has not been correctly 
initialized. Have you added the "google-services.json" file to the project? 

E/flutter ( 8043):     

E/flutter ( 8043): View the Android Installation documentation for more 
information: https://firebase.flutter.dev/docs/installation/android

E/flutter ( 8043): 

E/flutter ( 8043): #0      MethodChannelFirebase.initializeApp 
(package:firebase_core_platform_interface/src/method_channel
/method_channel_firebase.dart:88:9)

E/flutter ( 8043): <asynchronous suspension>

E/flutter ( 8043): #1      Firebase.initializeApp (package:firebase_core/src/firebase.dart:41:31)
E/flutter ( 8043): <asynchronous suspension>
E/flutter ( 8043): #2      main (package:riderapp/main.dart:14:3)
E/flutter ( 8043): <asynchronous suspension>
E/flutter ( 8043): 

pubspec,yaml

pubspec,yaml

  cupertino_icons: ^1.0.2
  firebase_core: ^1.0.3
  firebase_auth: ^1.0.2
  firebase_database: ^6.1.2
  fluttertoast: ^8.0.3

gradle/build.gradle

gradle/build.gradle

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

app/build.gradle

app/build.gradle

    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
// this is incase i get error archives can't exceed 64k
implementation 'com.android.support:multidex:1.0.3'
}

//apply plugin:
apply plugin: 'com.google.gms.google-services'

颤振干净-我尝试过扑得包-我试过了扑医生-v-我试过了

flutter clean - i tried flutter get packages - i tried flutter doctor -v - i tried

推荐答案

感谢@Nishuthan S为我发布解决方案.您可以在评论中看到他的建议.

Thank you to @Nishuthan S for posting the solution for me. As you can see in the comments what he suggested.

尝试 Flutter创建.然后 flutter clean ,然后 flutter run ,如果这样不起作用,则可以尝试备份lib文件夹并 pubspec 删除项目,创建一个新项目以相同的程序包名称替换lib和 pubspec

try flutter create . then flutter clean then flutter run if that doesn't work you can try back up your lib folder and pubspec delete the project create a new project in the same package name and replace lib and pubspec

按照他的建议去做后,我去阅读了图像,字体和声音,并将其返回给新项目.我输入了 flutter pub get 来检查pubspec.yaml是否工作正常.我将依赖关系从firebase读入正确的文件中,这取决于您自己的项目,可在其网站上找到.现在该项目正在运行.谢谢大家的帮助

After i did what he suggested, i went and readded the images, fonts and sounds back to the new project. I typed flutter pub get to check pubspec.yaml was working fine. I readded the dependencies from firebase into the correct files, this is found on their website depending on your own project. Now the project is working. Thanks to all for your help

这篇关于Firebase尚未正确初始化.您是否添加了"google-services.json"归档到项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆