You need to declare GOOGLE_MAPS_ANDROID_API_KEY in config.xml

After updating my google maps getting error in KEY. even my key was defined in my config.xml

FAILURE: Build failed with an exception.

  • Where:
    Script ‘/AppName/platforms/android/cordova-plugin-googlemaps/appName-apikey.gradle’ line: 39

  • What went wrong:
    A problem occurred evaluating script.
    You need to declare GOOGLE_MAPS_ANDROID_API_KEY in config.xml.

1 Like

Found the solution.

Not Working

<plugin name="cordova-plugin-googlemaps" spec="2.6.0">
        <variable name="API_KEY_FOR_ANDROID" value="***" />
        <variable name="API_KEY_FOR_IOS" value="***" />
 </plugin>

Solution (declare key outside from plugin tag and within widget tag)

<preference name="GOOGLE_MAPS_ANDROID_API_KEY" value="***" />
<preference name="GOOGLE_MAPS_IOS_API_KEY" value="****" />
9 Likes

@webumer Yes, you are correct.

2 Likes

The solution specified by @webumer is correct. You have to add preference with name as GOOGLE_MAPS_ANDROID_API_KEY for android and GOOGLE_MAPS_IOS_API_KEY for ios within the widget tag.

You can also find complete implementation of Google Maps using Ionic 4 at - https://ionic.tutorials24x7.com/blog/implement-google-maps-in-ionic-4-for-android

this worked for me…