我正试图在Android工作室上开发一个应用程序,并使用firebase工具。尽管我在lib firebase_options中有一个文件(用flutterfire配置创建),但它总是给我带来错误:
E/flutter: ERROR:flutter/lib/ui/ui_dart_state.cc(209)未处理的异常:'package:firebase_core_platform_interface/src/firebase_options.dart':失败断言:第61行pos 16:‘map’apiKey != null':'apiKey‘不能为空。#0 (package:firebase_core_platform_interface/src/firebase_options.dart:61:16) (省道:核心补丁/错误_补丁.dart:51:61) #1 _AssertionError._throwNew (省道:核心补丁/错误_补丁.dart:40:5) #2新FirebaseOptions.fromMap #3 _AssertionError._throwNew:45:23) #4 (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:35:10) #4 ListMixin.forEach (dart:collection/list.DAT:86:13) #5 MethodChannelFirebase._initializeCore MethodChannelFirebase._initializeCore #6 MethodChannelFirebase.initializeApp #7 Firebase.initializeApp (包:firebase_core/src/firebase)。dart:40:31) #8 main (包:my_firstapp/main.dart:13:3)
‘我的main.dart是:
import 'package:flutter/material.dart';
import 'package:my_firstapp/locator.dart';
import 'package:my_firstapp/models/user_model.dart';
import 'package:my_firstapp/screens/wrapper.dart';
import 'package:provider/provider.dart';
import 'package:my_firstapp/services/auth.dart';
import 'package:firebase_core/firebase_core.dart';
import 'firebase_options.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform,
);
setupServices();
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return StreamProvider<UserModel>.value(
value: AuthService().user,
initialData: null,
child: MaterialApp(
theme: ThemeData(
primaryColor: Color(0xff5FA55A),
secondaryHeaderColor: Color(0xff5FA55A),
),
home: Wrapper(),
),
);
}
}我能做什么,我被困在这个问题上了。请帮帮我
发布于 2022-05-04 11:08:12
firebase_options文件中缺少API键。打开firebase_options文件,检查第61行,以及Ctrl+f 'apiKey‘,以查找该文件中丢失的其他内容。
要查找API密钥,请执行以下操作:
Android应用程序Api键可以在google-services.json文件中找到,ios应用程序Api键可以在GoogleService-Info.plist
https://stackoverflow.com/questions/72110859
复制相似问题