Jip Harthoorn
Jip Harthoorn

Reputation: 302

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. 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:

<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.

These are my dependencies inside of 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

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!

Upvotes: 0

Views: 3034

Answers (1)

Phake
Phake

Reputation: 1349

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

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.

Upvotes: 2

Related Questions