Variables Treatment in Cordova Plugins

Hi, I am having an issue and I hope you can give me a hand.

I am trying to add a facebook login functionality using a cordova plugin. Basically what I am doing in the config.xml is as follows:

<gap:plugin name=“cordova-plugin-facebook” source=“npm”>
*variable name=“FACEBOOK_DISPLAY_NAME” value=“FRUGAS LP” />
*variable name=“FACEBOOK_APP_ID” value=“192837461234567” />
</gap:plugin>

Please read *variable as <variable

In this way, I was able to generate an apk file with phonegap build; however with volt, the app does not compile and in the log sends me the following error message:

Parse Error in config.xml: mismatched tag: line 16, column 6
Build c28c5f08-d734-4554-80ee-6659b054b5a9 failed

So… I did a test without variables, changing the facebook statement in the config.xml as follows:

<gap:plugin name=“cordova-plugin-facebook” source=“npm” />

In this time the error was different:

Running command: npm install cordova-plugin-facebook --save-dev
Command finished with error code 0: npm install,cordova-plugin-facebook,–save-dev
Copying plugin “/node_modules/cordova-plugin-facebook” => “/plugins/cordova-plugin-facebook”
Removing /plugins/cordova-plugin-facebook because mandatory plugin variables were missing.
Failed to restore plugin “cordova-plugin-facebook”. You might need to try adding it again. Error: CordovaError: Variable(s) missing (use: --variable FACEBOOK_APP_ID=value --variable FACEBOOK_DISPLAY_NAME=value).

Which is a logical error since I did not added the variable info, so I changed the syntax to the following:

<gap:plugin name=“cordova-plugin-facebook” source=“npm” --variable FACEBOOK_APP_ID=“192837461234567” --variable FACEBOOK_DISPLAY_NAME=“FRUGAS LP” />

and again an error:

error: Error: Invalid attribute name
Line: 22
Column: 57
Char: -

It seems that the “–” characters are not allowed so, I changed to the following:

<gap:plugin name=“cordova-plugin-facebook” source=“npm” variable FACEBOOK_APP_ID=“192837461234567” variable FACEBOOK_DISPLAY_NAME=“FRUGAS LP” />

Now the error was:

error: Error: Invalid attribute without value
Line: 22
Column: 66
Char: F

I also tried with different combinations:

<gap:plugin name=“cordova-plugin-facebook” source=“npm” variable=“FACEBOOK_APP_ID” value=“192837461234567” variable=“FACEBOOK_DISPLAY_NAME” value=“FRUGAS LP” />

<gap:plugin name=“cordova-plugin-facebook” source=“npm” FACEBOOK_APP_ID=“192837461234567” FACEBOOK_DISPLAY_NAME=“FRUGAS LP” />

But again the following error message:

Running command: npm install cordova-plugin-facebook --save-dev
Command finished with error code 0: npm install,cordova-plugin-facebook,–save-dev
Copying plugin “/node_modules/cordova-plugin-facebook” => “/plugins/cordova-plugin-facebook”
Removing /plugins/cordova-plugin-facebook because mandatory plugin variables were missing.
Failed to restore plugin “cordova-plugin-facebook”. You might need to try adding it again. Error: CordovaError: Variable(s) missing (use: --variable FACEBOOK_APP_ID=value --variable FACEBOOK_DISPLAY_NAME=value).

Does anyone has an idea of how the syntaxis should be? I presume that the sintaxis should be the same across the all the cordova plugins used in volt, so this should help us also with other plugins that requires variables.

Thanks in advance,
Adrian.

Tip: If you’re pasting code, html or config files, surround it by triple back ticks (```) and it will be fomatted properly.

I think your original solution is very close to being right.

Try removing the gap: from the plugin statements. They are not needed, since you’re not using PhoneGap.

Thanks for both tips… the first one I will take it into consideration for further posts.

The second one, made the plugin work smoothly.

Best Regards,
Adrian.