gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 23:26:28 28 4
gpt4 key购买 nike

当我运行我的应用程序时,我得到以下信息:
FirebaseException([核心/未初始化] Firebase 尚未正确初始化。您是否将“google-services.json”文件添加到项目中?查看 Android 安装文档了解更多信息:https://firebaseextended.github.io/flutterfire/docs/installation/android)
我 100% 确定我将“google-services.json”文件复制并粘贴到了正确的目录中:
安卓 > 应用
编辑:这是我的 main.dart 看起来像********************

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 studio中打开项目,让studio帮我将所有版本更新到最新最好的(我会厌倦这个,其中一些版本不是100%稳定的)
一旦我解决了这个问题,我就面临另一个问题......
“无法启动守护进程...等”,看起来我的环境指向了错误的 java 文件夹。它指向 x86/java JRE 文件夹。这是错误的!确保您指向 JDK 文件夹。
一旦我解决了这些问题,我的 flutter 应用程序就可以重新运行了。
我希望这对 future 的人有所帮助!
祝你好运,编程愉快!

关于firebase - Flutter FirebaseException(核心/未初始化异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64361723/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com