【发布时间】:2021-07-10 22:31:59
【问题描述】:
我正在尝试按照this 教程设置谷歌地图,但我遇到了一些问题。我的应用程序运行,但我看到一个白屏,没有任何事情发生,并且以下错误被打印到终端:
E/MethodChannel#flutter/platform_views(13225): Failed to handle method call
E/MethodChannel#flutter/platform_views(13225): java.lang.RuntimeException: API key not found. Check that <meta-data android:name="com.google.android.geo.API_KEY" android:value="your API key"/> is in the <application> element of AndroidManifest.xml
这很奇怪,因为我的AndroidManifest.xml 看起来像这样:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.studievriend">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application>
<meta-data android:name="com.google.android.geo.API_KEY" android:value="AIxxxxxxxxxxx-xxxxxxxxxxxxxxx_xxxxxx"/>
</application>
</manifest>
这正是错误所要求的,所以我不知道出了什么问题。我查看了其他线程并做了一些建议的事情,例如运行删除应用程序 flutter clean 并重试 flutter run,这也不起作用。
这些是我在 pubspec.yaml 中的依赖项
dependencies:
flutter:
sdk: flutter
location: ^4.1.1
cloud_firestore: ^1.0.5
firebase_core: ^1.0.3
google_maps_flutter: ^2.0.3
我也想添加geoflutterfire: ^2.0.2,但出现以下错误
Because geoflutterfire >=2.2.2 <3.0.0-nullsafety.1 depends on cloud_firestore ^0.16.0 and studievriend depends on cloud_firestore ^1.0.5, geoflutterfire >=2.2.2 <3.0.0-nullsafety.1 is forbidden.
So, because studievriend depends on geoflutterfire ^2.2.2, version solving failed.
我也尝试了一些其他版本,但我不断收到错误。
如果有人能帮我解决这个问题,我将不胜感激!
【问题讨论】:
标签: android flutter google-maps google-cloud-firestore