扑谷歌地图-找不到API密钥 [英] Flutter google maps - API key not found

查看:80
本文介绍了扑谷歌地图-找不到API密钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试按照教程,但我遇到了一些问题.我的应用程序正在运行,但我看到的是白屏,什么都没有发生,并且以下错误被打印到终端上:

I'm trying to set up google maps in flutter following this tutorial, but I'm running into some issues. 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

这很奇怪,因为我的 AndroidManifest.xml 看起来像这样:

Which is weird, because my AndroidManifest.xml looks like this:

<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 run ,这也行不通.

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.

这些是我在 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 ,但是随后出现以下错误

I would like to add geoflutterfire: ^2.0.2 aswell, but then I'm getting the following error

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!

推荐答案

您使用了错误的AndroidManifest.xml.请在app目录而不是debug目录中使用AndroidManifest.xml.调试清单仅用于抖动本身.正确的人应该在这个位置:

You used the wrong AndroidManifest.xml. Please use the AndroidManifest.xml in the app directory, not in the debug directory. The debug Manifest is only used for flutter itself. The right one should be in this location:

android\app\src\main\AndroidManifest.xml

对于其他错误,由于版本冲突,您可能需要导入较低版本的geoflutterfire.您导入了cloud_firestore:^ 1.0.5,但geofluttefire依赖于较新的版本.

For your other error, you might need to import a lower version of geoflutterfire, because there is a version conflict. You imported cloud_firestore: ^1.0.5 but the geofluttefire depends on a newer version.

这篇关于扑谷歌地图-找不到API密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆