Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache Cordova Facebook Plugin Fail On Init - Android

I'm currently building an app the will be using the Apache Cordova Facebook Plugin to communicate and authenticate users.

I had it working about a month ago, and then I was getting close to the end of development when I decided to upgrade to the newest version of Apache Cordova Facebook Plugin and Facebook SDK - now I cannot get it functioning.

I'm not sure if Facebook has changed something, or if Cordova Facebook Connect plugin has issues now - I am literally stuck :(

Here are the steps I'm taking and my results:

NOTE: I have deleted all programs and SDK's from my computer each time before attempting this to eliminate any cross version issues.

  • Create a Facebook App (followed instructions: https://developers.facebook.com/docs/android/getting-started#create-app)
    • Add Android Platform To App
    • Create a Key Hash using 'keytool' on OSX
      • keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64
  • Download latest Facebook SDK (https://developers.facebook.com/resources/facebook-android-sdk-current.zip)
  • Installed the Facebook APK (https://developers.facebook.com/docs/android/getting-started#install)
    • ./adb install ~/facebook-android-sdk-3.14/bin/FBAndroid-7.0.0.apk
  • Installed Eclipse Kepler Service Release 2
  • Installed the latest Android SDK (followed instructions: http://developer.android.com/sdk/installing/installing-adt.html)
  • Installed NodeJS (NPM 1.4.3) to install Cordova 3.4.1-0.1.0 (Terminal)
    • sudo npm install -g cordova
  • Create Cordova Application
    • cordova create hello com.example.hello "HelloWorld"
    • cd hello
    • cordova platform add android
    • cordova build
  • Installed Cordova Facebook Plugin
    • Installing using the command line interface (CLI):
      • cordova -d plugin add https://github.com/phonegap/phonegap-facebook-plugin.git --variable APP_ID="123456789" --variable APP_NAME="myApplication"
      • Fetching plugin "https://github.com/phonegap/phonegap-facebook-plugin.git" via git clone
      • Installing "com.phonegap.plugins.facebookconnect" for android
    • NOTE: I also have tried manual installing using the following instructions: https://github.com/phonegap/phonegap-facebook-plugin
  • Open Eclipse > File > Import > + Android > select Existing Android Code into Workspace
    • Import HelloWorld
    • Select App Properties > Android > add FacebookSDK as a library
    • Copy the "Simple" example that came with Cordova Facebook Connect (https://github.com/phonegap/phonegap-facebook-plugin/tree/master/example/Simple)
    • index.html is correctly linking to:
      • cordova.js
      • cdv-plugin-fb-connect.js
      • facebook-js-sdk.js
  • Project > Clean
  • Run with the Nexus S simulator

Once HelloWorld opens errors comes up:

  • Cordova Facebook Connect plugin fail on init
  • Cordova Facebook Connect plugin fail on auth.status

Like I said - I have tried manual installs and CLI installs, none will work!

Other versions that I have tried:

  • Cordova 3.3.0, 3.3.1, 3.4.0, 3.4.1
  • Facebook SDK 3.6, 3.7, 3.8, 3.9
  • Android Studio instead of Eclipse

This issue is causing major delay in our development and I have seen others online that are having the same problem, but no replies or answers.

Thanks for any help!

like image 243
Papa Wheelz Avatar asked May 09 '14 03:05

Papa Wheelz


1 Answers

Did you try fixing the target for config.xml for Facebook SDK 3.8.0 ? <config-file target="res/xml/config.xml" parent="/*"> <feature name="org.apache.cordova.facebook.Connect"> <param name="android-package" value="org.apache.cordova.facebook.ConnectPlugin" /> </feature> </config-file>

like image 88
cggaurav Avatar answered Oct 24 '22 00:10

cggaurav