androidfluttergoogle-mapsflutter-plugin

I/Process ( 8266): Sending signal. PID: 8266 SIG: 9 Lost connection to device


I am trying to integrate Google Maps into my Flutter project. I have followed these steps:

Generated a Google Maps API key. Enabled billing on my Google Cloud account. Added the necessary permissions and set up the android/app/src/main/AndroidManifest.xml file. Added the API key in the manifest. However, when I run the app, it crashes immediately without any error logs, and I cannot figure out why.

Can someone help me figure out what I might be missing or suggest ways to troubleshoot this issue?

E/flutter ( 3558): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:648:7)
E/flutter ( 3558): #1      Meth
W/.example.zoome( 3558): Accessing hidden field Ljava/net/Socket;->impl:Ljava/net/SocketImpl; (light greylist, reflection)
W/.example.zoome( 3558): Accessing hidden method Ldalvik/system/CloseGuard;->get()Ldalvik/system/CloseGuard; (light greylist, linking)
W/.example.zoome( 3558): Accessing hidden method Ldalvik/system/CloseGuard;->open(Ljava/lang/String;)V (light greylist, linking)
W/.example.zoome( 3558): Accessing hidden method Ljava/security/spec/ECParameterSpec;->setCurveName(Ljava/lang/String;)V (light greylist, reflection)
W/.example.zoome( 3558): Accessing hidden method Ldalvik/system/BlockGuard;->getThreadPolicy()Ldalvik/system/BlockGuard$Policy; (light greylist, linking)
W/.example.zoome( 3558): Accessing hidden method Ldalvik/system/BlockGuard$Policy;->onNetwork()V (light greylist, linking)
E/AndroidRuntime( 3558): FATAL EXCEPTION: androidmapsapi-ula-1
E/AndroidRuntime( 3558): Process: com.example.zoomer, PID: 3558
E/AndroidRuntime( 3558): 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
E/AndroidRuntime( 3558):    at com.google.maps.api.android.lib6.common.c.b(:com.google.android.gms.policy_maps_core_dynamite@243625205@243625202025.679729749.679729749:109)
E/AndroidRuntime( 3558):    at com.google.maps.api.android.lib6.impl.hg.run(:com.google.android.gms.policy_maps_core_dynamite@243625205@243625202025.679729749.679729749:571)
E/AndroidRuntime( 3558):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/AndroidRuntime( 3558):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/AndroidRuntime( 3558):    at java.lang.Thread.run(Thread.java:764)
I/Process ( 3558): Sending signal. PID: 3558 SIG: 9
Lost connection to device.

Solution

  • In my manifest file I have added:

    <meta-data android:name="com.google.android.geo.API_KEY"
                            android:value="${MAPS_API_KEY}" />
    

    I put this directly under the tag:

    <meta-data android:name="flutterEmbedding"
                            android:value="2" />
    

    And to not accidentally push the API key to git I added the key to the local.properties file like this:

    MAPS_API_KEY=api_key_here
    

    If all you've done the same, then maybe the last option is that you need to enable "Maps SDK for Android".

    Lastly check out the original package, if you did not yet do so: https://pub.dev/packages/google_maps_flutter