How can I install the facebookconnect cordova plugin?

那年仲夏 提交于 2020-01-05 07:49:10

问题


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

  • Apache Cordova Facebook Plugin BUILD FAILED
  • https://stackoverflow.com/questions/24175167/cordova-facebookconnect-compiling-error?rq=1

回答1:


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/




回答2:


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




回答3:


You can use the facebook plugin from cordova plugin registry.Here is the link (http://plugins.cordova.io/#/package/com.ccsoft.plugin.cordovafacebook).It supports cordova version above 3,also it requires android facebbok SDK.You can download from (https://developers.facebook.com/docs/android) here.




回答4:


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.



来源:https://stackoverflow.com/questions/25837802/how-can-i-install-the-facebookconnect-cordova-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!