Settings parameter in the config.xml cord to install the plugin

I have a cordova application that needs several plugins and you want to configure it using the config.xml file. For example, I need "plugin.google.maps", which requires the following variable during installation: API_KEY_FOR_ANDROID

If I do the following without specifying a plugin in config.xml , this works :

 cordova platform add android cordova plugin add plugin.google.maps --variable API_KEY_FOR_ANDROID="$MYKEY" 

It does not work if I insert my config.xml file:

 <feature name="cordova-plugin-app-version"> <param name="id" value="plugin.google.maps" /> <param name="API_KEY_FOR_ANDROID" value="$MYKEY" /> </feature> 

and then run

 cordova platform add android 

I get the following error:

 Installing "plugin.google.maps" for android Failed to install 'plugin.google.maps':Error: Variable(s) missing: API_KEY_FOR_ANDROID at /usr/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js:299:23 at _fulfilled (/usr/lib/node_modules/cordova/node_modules/q/q.js:787:54) at self.promiseDispatch.done (/usr/lib/node_modules/cordova/node_modules/q/q.js:816:30) at Promise.promise.promiseDispatch (/usr/lib/node_modules/cordova/node_modules/q/q.js:749:13) at /usr/lib/node_modules/cordova/node_modules/q/q.js:557:44 at flush (/usr/lib/node_modules/cordova/node_modules/q/q.js:108:17) at process._tickCallback (node.js:415:13) 

I find it difficult to find clear documentation on the plugin configuration in the config.xml file. Is this the right way to do this? What am I missing?

+5
source share
3 answers

I think you can do this by setting up your plugin as follows:

 <plugin name="cordova-plugin-app-version"> <param name="id" value="plugin.google.maps" /> <variable name="API_KEY_FOR_ANDROID" value="$MYKEY" /> </plugin> 

Hope this helps even after all this time;)

+3
source

read this, it may be useful for your failure "API_KEY_FOR_ANDROID"

https://github.com/wf9a5m75/phonegap-googlemaps-plugin/wiki/Phonegap-Usage

0
source

The name of the error and meaning clearly says that you must insert your key. You may have created the key from the Google console.

If you do not follow these steps to generate a key and a place.

  • Go to https://code.google.com/apis/console/ and sign in to your Google Account.

  • The following message will appear:

  • Click the "Create Project" button.

  • In the list of services, find the Google Maps API v3 and click "off" to turn it on.

  • On the next screen, check the box "I agree ..." and click "Accept" button. You will now see that the button next to the Google Maps API v3 has changed to "on".

  • Then click "Access API" on the left menu. He will ask you "Create an OAuth 2.0 client identifier ...".

  • On the next screen, specify the name of the product (for example, "demo"), upload the image (if you want) as the logo of your project and click the "Next" button.

  • On the next screen, select the type of application ("Web Application") and enter your web address and click "Create Client ID" button.

  • On the next screen, you have an API key.

Save the key for future reference.

-1
source

All Articles