Facebook plugin NullPointerException

It’s working fine on IOS, but I’m getting this exception as soon as the app starts up on Android. Android used to work, but I recently changed my app name and had to start re-building from scratch. I’m not quite sure what may have changed in the process.

I’ve installed the plugin via plugman (https://github.com/phonegap/phonegap-facebook-plugin) and done the additional manual step of linking.

The error occurs when I call the .getLoginStatus() method.

Any ideas?

06-02 15:05:19.273: E/PluginManager(27980): Uncaught exception from plugin
06-02 15:05:19.273: E/PluginManager(27980): java.lang.NullPointerException
06-02 15:05:19.273: E/PluginManager(27980): 	at org.apache.cordova.facebook.ConnectPlugin.execute(ConnectPlugin.java:205)
06-02 15:05:19.273: E/PluginManager(27980): 	at org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:65)
06-02 15:05:19.273: E/PluginManager(27980): 	at org.apache.cordova.PluginManager.execHelper(PluginManager.java:242)
06-02 15:05:19.273: E/PluginManager(27980): 	at org.apache.cordova.PluginManager.exec(PluginManager.java:227)
06-02 15:05:19.273: E/PluginManager(27980): 	at org.apache.cordova.ExposedJsApi.exec(ExposedJsApi.java:53)
06-02 15:05:19.273: E/PluginManager(27980): 	at org.apache.cordova.CordovaChromeClient.onJsPrompt(CordovaChromeClient.java:227)
06-02 15:05:19.273: E/PluginManager(27980): 	at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:655)
06-02 15:05:19.273: E/PluginManager(27980): 	at android.os.Handler.dispatchMessage(Handler.java:99)
06-02 15:05:19.273: E/PluginManager(27980): 	at android.os.Looper.loop(Looper.java:137)
06-02 15:05:19.273: E/PluginManager(27980): 	at android.app.ActivityThread.main(ActivityThread.java:5059)
06-02 15:05:19.273: E/PluginManager(27980): 	at java.lang.reflect.Method.invokeNative(Native Method)
06-02 15:05:19.273: E/PluginManager(27980): 	at java.lang.reflect.Method.invoke(Method.java:511)
06-02 15:05:19.273: E/PluginManager(27980): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
06-02 15:05:19.273: E/PluginManager(27980): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
06-02 15:05:19.273: E/PluginManager(27980): 	at dalvik.system.NativeStart.main(Native Method)

Seems to be an error involving the plugin…not so much with ionic. You may have better luck finding out the issue is if you post on the plugins git repo or SO.

Another option is this

http://coenraets.org/blog/2014/04/sociogram-angularjs-ionic-facebook/

Which is angular/ionic based and the plugin I believe is javascript based so no nasty native code errors

The author of OpenFB actually suggests using the Phonegap Facebook Plugin. Even though it is much easier to get it working than the plugin it has some major drawbacks like your user having to type in username/password on mobile devices and not being able to retrieve a long-term access token so it will expire in a couple hours as opposed to 6 months.

I started trying to get the Phonegap Facebook Plugin working but I ran into a bunch of issues and I used OpenFB to just get it working for now, I still need to get the Plugin working eventually.

Make sure you’re not using the master branch on the phonegap-facebook-plugin repo. This is supposedly broken.

I can’t find the comment right now but one of the devs was saying to pull the develop branch because it’s more up to date. https://github.com/phonegap/phonegap-facebook-plugin/tree/develop

Could you post more info on how you got it working this far? I’ve been struggling with it. Thanks!

Found it…

1 Like

Thanks for the info @seanion . I’m not quite sure what info to post about how I got it working, but if you ask about specific issues I’ll be happy to try address them.

I see that you were able to fix this issue using the workaround here: