I have a cordova app which needs several plugins and want to configure it using the config.xml file. For instance, i need the 'plugin.google.maps' which needs the following variable when installing : API_KEY_FOR_ANDROID
If i do the following without specifying the plugin in config.xml
, this works:
cordova platform add android
cordova plugin add plugin.google.maps --variable API_KEY_FOR_ANDROID="$MYKEY"
It doesn't work if i put in 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'm having a hard time finding clear documentation on plugin configuration in config.xml. Is it the proper way to do this? What am i missing?
I think you can do it configuring your plugin as following :
<plugin name="cordova-plugin-app-version">
<param name="id" value="plugin.google.maps" />
<variable name="API_KEY_FOR_ANDROID" value="$MYKEY" />
</plugin>
Hope that helps even after all this time ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With