9

When I do :

cordova plugin add https://github.com/phonegap/phonegap-facebook-plugin.git

I get the error :

Error: Variable(s) missing: APP_ID, APP_NAME

Where do I have to configure these variables ?

Cherif
  • 5,223
  • 8
  • 33
  • 54

4 Answers4

12

Look at the bottom of the README.md file on that github repository. You'll see it gives you instructions for installing the plugin and including the variables:

plugman install --platform [PLATFORM] --project [TARGET-PATH] --plugin [PLUGIN-PATH] --variable APP_ID="[APP_ID]" --variable APP_NAME="[APP_NAME]"

where
    [PLATFORM] = ios or android
    [TARGET-PATH] = path to folder containing your phonegap project
    [PLUGIN-PATH] = path to folder containing this plugin
    [APP_ID] = Your APP_ID as registered on Facebook

The Cordova CLI uses Plugman behind the scenes, so you can use it to inject variable names like this:

cordova plugin add https://github.com/phonegap/phonegap-facebook-plugin.git --variable APP_ID="my-app-id" --variable APP_NAME="my-app-name"
MBillau
  • 5,366
  • 2
  • 28
  • 29
  • 1
    but still `cordova platform add android` didn't work for me. I had to finally hack the hook scripts at `hooks/after_platform_add/010_install_plugins.js` and add the `--variable ......`. – nidheeshdas Feb 10 '15 at 05:35
  • i believe it still compiles everything even if it kicks back the APP_ID, APP_NAME error. – Elon Zito Mar 02 '16 at 18:08
  • I am also getting same error while building with jenkins on ubuntu ...... When we use : cordova plugin add cordova-plugin-facebook --variable APP_NAME=PatientConnect360 --variable APP_ID=XXXX --save we get error : Failed to install 'cordova-plugin-facebook': Error: Variable(s) missing: FACEBOOK_APP_ID, FACEBOOK_DISPLAY_NAME ..... and when we use : cordova plugin add cordova-plugin-facebook --variable FACEBOOK_DISPLAY_NAME=PatientConnect360 --variable FACEBOOK_APP_ID=XXXXX --save – Ashish Karpe Dec 12 '17 at 06:58
  • we get error : Failed to install 'cordova-plugin-facebook4': Error: Variable(s) missing: APP_ID, APP_NAME Error: Variable(s) missing: APP_ID, APP_NAME – Ashish Karpe Dec 12 '17 at 06:58
11

Edit the following lines in plugins\com.phonegap.plugins.facebookconnect\plugins.xml:

<preference name="APP_ID" />
<preference name="APP_NAME" />

To:

<param name="APP_ID" value="123456789" />
<param name="APP_NAME" value="Cordova" />
Alastair
  • 6,837
  • 4
  • 35
  • 29
henkie14
  • 949
  • 9
  • 7
  • 2
    I have a pb here: I don't check my plugins directory into version control. It seems logic not to. Is there any other way to fix this ? – Ruff9 Jan 02 '17 at 15:51
  • You can add the variable to the tag in your application's config.xml. See the section on variables here: https://cordova.apache.org/docs/en/latest/config_ref/index.html#plugin – Shoerob Mar 30 '17 at 22:14
2

To use this plugin you will need to make sure you've registered your Facebook app with Facebook and have an APP_ID (https://developers.facebook.com/apps).

If you plan on rolling this out on iOS, please note that you will need to ensure that you have properly set up your Native iOS App settings on the Facebook App Dashboard. Please see the Getting Started with the Facebook SDK: Create a Facebook App section, for more details on this.

If you plan on rolling this out on Android, please note that you will need to generate a hash of your Android key(s) and submit those to the Developers page on Facebook to get it working. Furthermore, if you are generating this hash on Windows (specifically 64 bit versions), please use version 0.9.8e or 0.9.8d of OpenSSL for Windows and not 0.9.8k. Big ups to fernandomatos for pointing this out!

iamsuman
  • 1,413
  • 19
  • 32
1

I am using DevExtreme - maybe it run in anothers plataforms - and I had the same problem. I late to resolve because when I changed my config.xml to set APP_ID and APP_NAME and after create .zip to use phonegap's build, this params(APP_ID and APP_NAME) disappeared of config.xml. The solution was edit config.xml after create .zip, not before like I did.

Obs: While I was researching about this, I saw many developers having the same problem. To resolve it, they fixed your .xml with this test http://www.w3schools.com/xml/xml_validator.asp

I hope this help.

Doglas
  • 642
  • 1
  • 11
  • 22