[英]Flutter google maps - API key not found
I'm trying to set up google maps in flutter following this tutorial, but I'm running into some issues.我正在尝试按照本教程在 flutter 中设置谷歌地图,但我遇到了一些问题。 My app runs but I'm seeing a white screen without anything happening and the following error is printed to the terminal:
我的应用程序运行,但我看到一个白屏,没有任何事情发生,并且以下错误被打印到终端:
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
Which is weird, because my AndroidManifest.xml
looks like this:这很奇怪,因为我的
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>
It's exactly what the error is asking for so I don't know what's wrong.这正是错误所要求的,所以我不知道出了什么问题。 I've looked at other threads and done some suggested things like running removing the application,
flutter clean
and retry flutter run
, which is also not working.我查看了其他线程并做了一些建议的事情,比如运行删除应用程序、
flutter clean
试flutter run
,这也不起作用。
These are my dependencies inside of pubspec.yaml
这些是我在
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
I would like to add geoflutterfire: ^2.0.2
aswell, but then I'm getting the following error我也想添加
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.
I've tried some other versions aswell but I keep getting errors.我也尝试了一些其他版本,但我不断收到错误。
I would really appreciate it if someone can help me with this!如果有人可以帮助我,我将不胜感激!
You used the wrong AndroidManifest.xml.您使用了错误的 AndroidManifest.xml。 Please use the AndroidManifest.xml in the app directory, not in the debug directory.
请使用app目录下的AndroidManifest.xml,而不是debug目录下。 The debug Manifest is only used for flutter itself.
调试清单仅用于 flutter 本身。 The right one should be in this location:
正确的应该在这个位置:
android\app\src\main\AndroidManifest.xml
For your other error, you might need to import a lower version of geoflutterfire, because there is a version conflict.对于您的其他错误,您可能需要导入较低版本的 geoflutterfire,因为存在版本冲突。 You imported cloud_firestore: ^1.0.5 but the geofluttefire depends on a newer version.
您导入了 cloud_firestore: ^1.0.5 但 geofluttefire 依赖于较新的版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.