Search code examples
androidfacebookcordovaplugins

PhoneGap Facebook plugin connect with Android


I have a problem using the Facebook Connect plugin with PhoneGap.

I have added this line to file plugins.xml:

<plugin name="com.phonegap.facebook.Connect" value="com.phonegap.facebook.ConnectPlugin" />

And this include on in file FbDialog.java:

import com.phonegap.helloworld.R;

I have these files on src:

com
   /facebook/android/
                     AsyncFacebookRunner.java
                     DialogError.java
                     Facebook.java
                     FacebookError.java
                     FbDialog.java
                     Util.java
   /phonegap/
             facebook/ConnectPlugin.java
             helloworld/HelloPhoneGapActivity.java

The ressources files close and the icon is copied. In HTML, I include some JavaScript code:

cordova-1.6.1.js
cdv-plugin-fb-connect.js
facebook_js_sdk.js

I use the default HTML example with my appId.

When I run application on my Android phone, a dialog says:

Cordova Facebook connect plugin fail on init!

and

Cordova Facebook connect plugin fail on auth.status!

If I click the login bouton, the dialog says:

Cordova Facebook connect plugin fail on login!Class not found

And the Eclipse console log is:

Enter image description here

I tried to install this with the officiel Git readme and the tutorial Add Facebook login to PhoneGap/Cordova Android app Easiest way.

When I compile the application, I don't get the error.

How do I fix this problem?


Solution

  • After the switch to Cordova, everything got renamed. You need the new class location:

    <plugin name="org.apache.cordova.facebook.Connect" value="org.apache.cordova.facebook.ConnectPlugin" />
    

    You'll have to put your plugin java (back?) to the correct location as well in org/apache/cordova/facebook/ .

    Unfortunately, the error for this is pretty vague, but you can see it if you know what to look for. You can see in your logs the line with Message=Class not found in it. It would be better if this line had the name of the class. This error happens when you call the JS for a plugin, but then the right class name can't be found in the plugins.xml file. This is also why you notice that any call fails the same way.