简体   繁体   中英

How can I install the facebookconnect cordova plugin?

I am trying to use the com.phonegap.plugins.facebookconnect plugin. To install it, I must provide two variables, like this:

cordova plugin add com.phonegap.plugins.facebookconnect --variable APP_ID="<app_id>" --variable APP_NAME="<app_name>"

This works, but then the build fails because of this issue .

BUILD FAILED
/Applications/Android Studio.app/sdk/tools/ant/build.xml:720: The following error occurred while executing this line:
/Applications/Android Studio.app/sdk/tools/ant/build.xml:734: Compile failed; see the compiler error output for details.

Total time: 6 seconds

.../platforms/android/cordova/node_modules/q/q.js:126
                    throw e;
                          ^
Error code 1 for command: ant with args: debug,-f,.../platforms/android/build.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen
Error: .../platforms/android/cordova/run: Command failed with exit code 8
    at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:135:23)
    at ChildProcess.emit (events.js:98:17)
    at maybeClose (child_process.js:755:16)
    at Process.ChildProcess._handle.onexit (child_process.js:822:5)

The traditional way to solve the aforementioned issue is to remove all platforms and add them again. The problem is that when the platforms are added, they try to install the plugin for themselves, but don't pass in the variables the plugin needs to correctly install, resulting in:

Failed to install 'com.phonegap.plugins.facebookconnect':Error: Variable(s) missing: APP_ID, APP_NAME
    at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js:301:23
    at _fulfilled (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:798:54)
    at self.promiseDispatch.done (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:827:30)
    at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:760:13)
    at /usr/local/lib/node_modules/cordova/node_modules/q/q.js:574:44
    at flush (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:108:17)
    at process._tickCallback (node.js:419:13)
Error: Variable(s) missing: APP_ID, APP_NAME
    at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js:301:23
    at _fulfilled (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:798:54)
    at self.promiseDispatch.done (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:827:30)
    at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:760:13)
    at /usr/local/lib/node_modules/cordova/node_modules/q/q.js:574:44
    at flush (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:108:17)
    at process._tickCallback (node.js:419:13)

So I get either a correctly installed plugin, but a failing build, or an incorrectly installed plugin and a passing build.

This makes it impossible to use the facebookconnect plugin, because, of course, the plugin needs to be installed correctly AND the build needs to pass.

Any quick solution for this?

more info

$ cordova -v
3.5.0-0.2.7

related questions

Don't ever include facebook android library into your cordova project. Use these libraries instead that one.

https://github.com/phonegap-build/FacebookConnect/tree/master/src/android/facebook

Reference: http://blog.revivalx.com/2014/05/20/integration-cordova-facebook-connect-plugin-for-android/

To avoid the cordova issue, don't try building with cordova. Just use cordova to create the project, add platforms, and add plugins (in that order). Then, use xcode or android studio or visual studio to build and run. This is what solved the problem for me.

Also, don't add the plugin with the registry. Download the zip file, uncompress it, and then add it locally. Thanks to @tapmonkey for the following link which explains this:

https://stackoverflow.com/a/25327341/585580

您可以从cordova插件注册表中使用facebook插件。这里是链接( http://plugins.cordova.io/#/package/com.ccsoft.plugin.cordovafacebook)。它支持3以上的cordova版本,也需要android facebbok SDK。您可以在此处( https://developers.facebook.com/docs/android )下载。

Just run your same command with sudo ,because it requires root access.

sudo cordova plugin add com.phonegap.plugins.facebookconnect --variable APP_ID="<app_id>" --variable APP_NAME="<app_name>"

type password if it will ask, and you are good togo.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM