I am a beginner to smack. Trying to connect to server and send a test text message. stuck here with errors shown in red.
try {
XMPPTCPConnectionConfiguration.Builder configBuilder = XMPPTCPConnectionConfiguration.builder();
configBuilder.setUsernameAndPassword(“username”, “password”);
configBuilder.setResource(“SomeResource”);
//Error shown here >>> setServiceName (org.jxmpp.jid.DomainBareJid) in Builder cannot be applied to (java.lang.String)
configBuilder.setServiceName(“servername”);
AbstractXMPPConnection connection = new XMPPTCPConnection(configBuilder.build());
connection.connect();
connection.login();
// Assume we’ve created an XMPPConnection name “connection”._
ChatManager chatmanager = ChatManager.getInstanceFor(connection);
//Error shown here >>> (Wrong 1st argument type. Found: ‘java.lang.String’, required: 'org.jxmpp.jid.EntityJid)
Chat newChat = chatmanager.createChat(“to”, chatListener);
newChat.sendMessage(“Howdy!”);
} catch (SmackException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (XMPPException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
//Imports are below
import org.jivesoftware.smack.AbstractXMPPConnection;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.chat.Chat;
import org.jivesoftware.smack.chat.ChatManager;
import org.jivesoftware.smack.chat.ChatMessageListener;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.tcp.XMPPTCPConnection;
import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration;