Reputation: 5731
In my app, Instead of using SASLAuthentication such as X-FACEBOOK-PLATFORM, I'm using Facebook Jabber ID method for login.
From this reference, I got the following piece of code
public void connectToFb() throws XMPPException {
ConnectionConfiguration config = new ConnectionConfiguration("chat.facebook.com", 5222);
config.setSASLAuthenticationEnabled(true);
config.setSecurityMode(SecurityMode.required);
config.setRosterLoadedAtLogin(true);
config.setTruststorePath("/system/etc/security/cacerts.bks");
config.setTruststorePassword("changeit");
config.setTruststoreType("bks");
config.setSendPresence(false);
try {
SSLContext sc = SSLContext.getInstance("TLS");
sc.init(null, MemorizingTrustManager.getInstanceList(this), new java.security.SecureRandom());
config.setCustomSSLContext(sc);
} catch (GeneralSecurityException e) {
Log.w("TAG", "Unable to use MemorizingTrustManager", e);
}
XMPPConnection xmpp = new XMPPConnection(config);
try {
xmpp.connect();
xmpp.login("facebookusername", "****"); // Error on this line
Roster roster = xmpp.getRoster();
Collection<RosterEntry> entries = roster.getEntries();
System.out.println("Connected!");
System.out.println("\n\n" + entries.size() + " buddy(ies):");
// shows first time onliners---->
String temp[] = new String[50];
int i = 0;
for (RosterEntry entry : entries) {
String user = entry.getUser();
Log.i("TAG", user);
}
} catch (XMPPException e) {
xmpp.disconnect();
e.printStackTrace();
}
}
I used smack 3.3.0 api, uses_INTERNET permission, and the steps mentioned there(MemorizingTrustManager).
But I'm getting error.
04-21 15:18:44.589: E/AndroidRuntime(2811): FATAL EXCEPTION: main
04-21 15:18:44.589: E/AndroidRuntime(2811): java.lang.VerifyError: org.jivesoftware.smack.sasl.SASLMechanism
04-21 15:18:44.589: E/AndroidRuntime(2811): at java.lang.Class.getDeclaredConstructors(Native Method)
04-21 15:18:44.589: E/AndroidRuntime(2811): at java.lang.Class.getConstructor(Class.java:472)
04-21 15:18:44.589: E/AndroidRuntime(2811): at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java:314)
04-21 15:18:44.589: E/AndroidRuntime(2811): at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:221)
04-21 15:18:44.589: E/AndroidRuntime(2811): at org.jivesoftware.smack.Connection.login(Connection.java:366)
04-21 15:18:44.589: E/AndroidRuntime(2811): at com.activapps.fbchat.MainActivity.connectToFb(MainActivity.java:61)
Having profile like www.facebook.com/nizam.cs ; I used user id as nizam.cs, [email protected] & [email protected] for login but none of those worked.
What am I missing?
I tested it on emulator without a facebook sdk.
Upvotes: 2
Views: 616
Reputation: 5731
Problem solved! :)
The problem was with the smack library that I used. Instead of smack3.3.0, used asmack-android-6.jar which is an update SMACK library: smack with xep0280 and xep0184.
That solved the connectivity problem.
Upvotes: 1