Flutter FirebaseException(核心/未初始化异常



当我运行应用程序时,我会得到以下信息:

FirebaseException([core/not-initialized]Firebase未正确初始化。您是否已将"googleservices.json"文件添加到项目中?查看Android安装文档以了解更多信息:https://firebaseextended.github.io/flutterfire/docs/installation/android)

我100%确信我复制并粘贴了我的";googleservices.json";正确目录中的文件:

android>应用

编辑:这是我的主要部分。艺术看起来像*******************

void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// Create the initialization Future outside of `build`:
final Future<FirebaseApp> _initialization = Firebase.initializeApp();
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return FutureBuilder(
// Initialize FlutterFire:
future: _initialization,
builder: (context, snapshot) {
// Check for errors
if (snapshot.hasError) {
return Center(
child: Text("Someting went Worng"),
);
}
// Once complete, show your application
if (snapshot.connectionState == ConnectionState.done) {
return StreamProvider<SignedInUser>.value(
value: AuthService().user,
child: MaterialApp(
home: Wrapper(),
),
);
}
// Otherwise, show something whilst waiting for initialization to complete
return CircularProgressIndicator();
},
);
}
}

请帮忙!

提前谢谢!

好吧,伙计们,花了几个小时试图找到解决这个问题的方法,我终于解决了!

所以,看起来我没有在android文件夹中正确配置我的gradle文件。这很重要(显然(!我缺少apply plugin: 'com.google.gms.google-services'然后我当然是偏执狂,决定在android工作室打开这个项目,让工作室帮助我将所有版本更新到最新和最棒的版本(我会对此感到厌倦,其中一些版本不是100%稳定的(

一旦我解决了这个问题,我就面临着另一个问题。。。

"无法启动后台程序。。。等等";,看起来我的环境指向了错误的java文件夹。它指向x86/java JRE文件夹。这是错误的!请确保指向JDK文件夹。

一旦我解决了这些问题,我的flutter应用程序就可以正常工作了。

我希望这对将来的人有所帮助!

祝你好运,编程愉快!

您应该遵循Firebase的Android安装指南,其中列出:

  • 注册Android应用程序后,从Firebase控制台下载配置文件(该文件名为googleservices.json(。将该文件添加到Flutter项目中的Android/app目录中。

  • classpath 'com.google.gms:google-services:4.3.8'添加到android/build.gradle

  • apply plugin: 'com.google.gms.google-services'添加到android/app/build.gradle

只是为了了解哪些人仍然有同样的问题没有得到解决。您可以尝试在Build.gradle\app 中插入此代码

rootProject.ext{set("FlutterFire"[FirebaseSDK版本:"25.12.0"])}

别忘了在pubspec.yaml 中插入此代码

firebase_core:"^0.5.2〃;

最新更新