FATAL EXCEPTION – cordova.facebook.ConnectPlugin-Collection of common programming errors
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();
Ref : NetworkOnMainThreadException on Facebook Login with Phonegap 1.6.0