Import facebook SDK into cordova / phonegap project

I am building my first application using cordova 3.3.0 (aka phonegap). Everything is in order: I can run the project on Android Device Emulator and on my mobile.

I would like to use the plugin to connect facebook: https://github.com/phonegap/phonegap-facebook-plugin

But all the documentation I read (specifically: https://developers.facebook.com/docs/android/getting-started ) explains how to set up the Facebook SDK through Eclipse. I also found a document on how to install in AndroΓ―d Studio.

I do not want to install any of them, I do everything on the command line, since I like to know how everything works (at least for my first project ...).

So the question is: how do I import the SDK into your cordova project?

Thanks for your ideas!

+6
source share
2 answers

Well, I found the answer, struggled with the same problem. I really tried to get an ionic cord project to use facebook plugin

You need to go to the Platform / android folder of your cordova project. At the moment, you are simply dealing with a regular Android project.

run the following command

android update project --target 3 --path C:\Users\<yourname>\Documents\Projects\<projectName>\ionic\platforms\android --library ../../../../facebook-android-sdk-3.7/facebook

Ok, a couple of tricks

  • The -library argument should be relative to your Android project. And the library argument should refer to the facebook file you downloaded (as part of the instructions for the facebook plugin).
  • You must have API level 8 on the Android SDK.
  • Once the command completes, go to local.properties and verify that sdk.dir is installed correctly. I had double slashes, I had to fix it.
  • go to the project. properties and you should see something like the following

    android.library.reference.1 = CordovaLib

    android.library.reference.2 = .. / .. / .. / .. / facebook-android-sdk-3.7 / facebook target = android-18 '

Hope this helps someone, I also don't really like using eclipse for a phone saver.

+8
source

Today I encountered the same problem with the corridor 3.3. A solution similar to another may possibly be useful. I am on linux environemnt

I managed to create:

plugin installation

 cordova plugin add https://github.com/phonegap/phonegap-facebook-plugin.git --variable APP_ID="yourvalues" --variable APP_NAME="yourvalues" cd /platforms/android 

add this line to project.properties

 android.library.reference.2=FacebookLib 

update project

 android update project --subprojects --path . --target "android-19" 

Then compiled with

 cordova build 
+1
source

All Articles