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.
3 Likes
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="****" />
13 Likes
@webumer Yes, you are correct.
# Release notes version 2.6.0
## API Key
cordova-plugin-googlemaps version 2.6.0 changes installation way.
From this version, you need to specify your API key in `config.xml` file.
```xml
<widget ...>
...
<preference name="GOOGLE_MAPS_ANDROID_API_KEY" value="(api key)" />
<preference name="GOOGLE_MAPS_IOS_API_KEY" value="(api key)" />
...
</widget>
```
Installation of this plugin becomes easy. Just install this plugin like other ones.
```
$> cordova plugin add cordova-plugin-googlemaps
This file has been truncated. show original
4 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