Uncaught Exception Theme in Facebook Plugin for Phonegap

I am trying to implement a facebook API plugin for Phonegap using the following plugin ... https://github.com/phonegap/phonegap-facebook-plugin/issues/183

I followed the installation guide and I am using Phonegap 2.9.0. For testing, I use the example presented in the project (both a hacker and a simple one). And the application works in Android Jelly Bean 4.2.2

But whenever I tried the login with a facebook example, after clicking OK when authenticating the application, the Android application suddenly stopped.

Any suggestion where I should check?

Here is the LogCat error:

07-21 12:25:10.568: W/dalvikvm(4288): threadid=1: thread exiting with uncaught exception (group=0x40e32930) 07-21 12:25:10.568: E/AndroidRuntime(4288): FATAL EXCEPTION: main 07-21 12:25:10.568: E/AndroidRuntime(4288): java.lang.NullPointerException 07-21 12:25:10.568: E/AndroidRuntime(4288): at org.apache.cordova.facebook.ConnectPlugin$AuthorizeListener.onComplete(ConnectPlugin.java:283) 07-21 12:25:10.568: E/AndroidRuntime(4288): at com.facebook.android.Facebook.onSessionCallback(Facebook.java:345) 07-21 12:25:10.568: E/AndroidRuntime(4288): at com.facebook.android.Facebook.access$11(Facebook.java:326) 07-21 12:25:10.568: E/AndroidRuntime(4288): at com.facebook.android.Facebook$1.call(Facebook.java:304) 07-21 12:25:10.568: E/AndroidRuntime(4288): at com.facebook.Session$3$1.run(Session.java:1190) 07-21 12:25:10.568: E/AndroidRuntime(4288): at android.os.Handler.handleCallback(Handler.java:725) 07-21 12:25:10.568: E/AndroidRuntime(4288): at android.os.Handler.dispatchMessage(Handler.java:92) 07-21 12:25:10.568: E/AndroidRuntime(4288): at android.os.Looper.loop(Looper.java:137) 07-21 12:25:10.568: E/AndroidRuntime(4288): at android.app.ActivityThread.main(ActivityThread.java:5227) 07-21 12:25:10.568: E/AndroidRuntime(4288): at java.lang.reflect.Method.invokeNative(Native Method) 07-21 12:25:10.568: E/AndroidRuntime(4288): at java.lang.reflect.Method.invoke(Method.java:511) 07-21 12:25:10.568: E/AndroidRuntime(4288): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795) 07-21 12:25:10.568: E/AndroidRuntime(4288): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562) 07-21 12:25:10.568: E/AndroidRuntime(4288): at dalvik.system.NativeStart.main(Native Method) 07-21 12:25:19.787: I/Process(4288): Sending signal. PID: 4288 SIG: 9 
+4
source share
2 answers

addition to @ umesh25, if you use cordova 2.9, this is already fixed, just comment on the logger that raises a NullPointerException

 277. Log.d(TAG, values.toString()); 
+2
source

In ConnectPlugin.java, replace:

 try { JSONObject o = new JSONObject(this.fba.facebook.request("/me")); this.fba.userId = o.getString("id"); this.fba.success(getResponse(), this.fba.callbackId); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } 

with the following code:

 Thread t = new Thread(new Runnable() { public void run() { try { JSONObject o = new JSONObject(fba.facebook.request("/me")); fba.userId = o.getString("id"); fba.success(getResponse(), fba.callbackId); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); t.start(); 

Link: NetworkOnMainThreadException on Facebook Login using Phonegap 1.6.0

+2
source

Source: https://habr.com/ru/post/1492543/


All Articles