【发布时间】:2020-03-11 01:18:08
【问题描述】:
一个非常简单的应用程序,只有一个谷歌地图屏幕,从 Codelabs 复制,具有以下内容:
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('Maps Sample App'),
backgroundColor: Colors.green[700],
),
body: GoogleMap(
onMapCreated: _onMapCreated,
initialCameraPosition: CameraPosition(
target: _center,
zoom: 11.0,
),
),
),
);
}
在运行应用程序时崩溃,我得到以下堆栈:
==========================================
*** First throw call stack:
(
0 CoreFoundation 0x00007fff23c7127e __exceptionPreprocess + 350
1 libobjc.A.dylib 0x00007fff513fbb20 objc_exception_throw + 48
2 CoreFoundation 0x00007fff23c710bc +[NSException raise:format:] + 188
3 Runner 0x00000001050730e3 +[GMSServices checkServicePreconditions] + 182
4 Runner 0x000000010506ff22 +[GMSServices sharedServicesSync] + 110
5 Runner 0x000000010505f979 -[GMSMapView sharedInitWithServices:camera:forPlaces:] + 156
6 Runner 0x000000010505ede1 -[GMSMapView initWithFrame:camera:] + 123
7 Runner 0x000000010505ec05 +[GMSMapView mapWithFrame:camera:] + 104
8 Runner <…>
Lost connection to device.
=============================================
使用的插件是:google_maps_flutter: ^0.5.11
这里发生了什么?
【问题讨论】:
-
您是否将 Google 地图的 google_api_key 添加到您的 Flutter 应用中?如果没有,请关注readMe。
-
是的,API 已添加到 AppDelegate.m 并且 info.plist 已按照说明进行编辑。有趣的是,我有一个较旧的应用程序,可以追溯到大约一年前,它可以在 Google 地图上正常运行,但我无法创建任何可以运行的新应用程序。
标签: google-maps flutter